Start by defining the temperature of an object, which is usually done by construction of suitable measurement devices as thermometers, whose working principles will not be discussed here (as it would take us far from the point).
Once you have a thermometer you can measure the temperatures of two different objects, say $T_1$ and $T_2$. It is an experimental fact that, after putting in contact two such objects with $T_1 > T_2$, the system will reach an equilibrium state with the two bodies having the same temperature (that, again, can be measured via a thermometer).
When such happens, it is possible to experimentally build machines (see Carnot and similars) capable of doing mechanical work whilst operating between two sources at different temperatures. This is interpreted as the fact that thermal differences force the exchange of thermal energy, which can be quantified by the amount of mechanical work such machines can perform. By definition, thermal energies exchanges are called heat in the standard terminology.