This is a fundamental principle of thermodynamics, known as the second law of thermodynamics. It states that heat energy will always flow spontaneously from a region of higher temperature to a region of lower temperature, until both regions reach thermal equilibrium (the same temperature).
Here's an analogy: Imagine a hill with water at the top. Water naturally flows downhill, from a higher point to a lower point. Similarly, heat naturally flows from a hotter object to a colder object.