The concept of temperature was defined by the so-called zeroth law of thermodynamics. In the most formal way the law was expressed in a form of the following statement [after Resnick and Halliday]: "There exists a scalar quantity called temperature which is a property of all thermodynamic systems in equilibrium. Two systems are in thermal equilibrium if and only if their temperatures are equal". This issue is elaborated in their book "Fundamentals of Physics. Part I".
In quantum physics, people fit Plank distribution to probabilities of particle at 2 energy levels. This way you can get negative temperatures as well (if levels inversion like in laser happens). Also, 0th law of thermodynamics is somewhat arbitrary: it define if some system hotter (or colder) than other, but do not specify temperature ratios. Using system energy as value proportional to temperature is convenient, but it is not the only way. It was chosen historically because with this relation the thermal capacities of most materials are nearly constant at room temperature, simplifying math. You can use any monotonic function of energy to define custom "temperature" - if it suit your application.
In thermophysics different temperatures can be defined from each degree of freedom of a molecule being in (partial) thermodynamic equilibrium: translation,rotation, vibration. The temperature is defined as a parameter giving the statistical description of states: Maxwell distribution for translation, Boltzmann for rotation and vibration. In the total thermodynamic equilibrium both of these values are identical.
Simply, temperature is a measure of the molecular activity of a substance, which expresses the degree of hotness or coldness, measured on a definite scale. It cannot be measured directly but it is measured by its effect (relative expansion, change of state…..)