It's common knowledge that mammals, unlike for example reptiles, have warm blood and generate heat inside their bodies at all times. For many years, researchers in the field of evolution have been trying to decipher the mystery of this difference, and especially how warm-blooded creatures came to be in the first place. They say that, most likely, mammals evolved this trait in order to gain the ability of moving freely and for longer periods of time than other beasts in their habitats.
However, the main issue with endothermy is that it's extremely wasteful in terms of bodily resources, as proven by the fact that an average human, left without food, could only survive for about two months, whereas a crocodile could easily get past an entire year without consuming anything. The reason for this is very simple – people waste an enormous amount of the food they ingest on generating heat throughout their bodies, whereas the reptile has no need for this. In terms of survivability over extended periods of time, they outpass humans by miles.
However, we win when it comes to stamina. That is to say, we can travel a lot longer on our own in any time frame, as opposed to a cold-blooded animal. And not necessarily because we have long feet, but due to the fact that our blood allows for it. The energy that is generated from our food, the process that also yields our inner heat, can fuel our muscles for extended periods of time, by supplying high amounts of oxygen, the substance needed to produce muscular contractions.
In evolutionary terms, this trait may have evolved as an adaptation to the environment, when mammals needed to give birth to offspring in the relative safety of a den or other makeshift shelter. The cubs also remained active in the cold, which allowed mammals to continue going about their business in the winter as well. This gave them an edge over reptiles, and allowed them to diversify in countless species. Over time, some of the species learned to adjust the temperature in some of their organs, while others got used to adapting their entire bodily temperatures altogether.
Moreover, warm-blooded creatures may have evolved out of the necessity to avoid going out in the open, in order to capture the heat from the Sun, such as reptiles do today. This would have allowed the earliest mammals to live a peaceful life, a fact that is in tone with a recent evolutionary theory, which states that endothermy first appeared in herbivores, rather than carnivores, as first thought. In the end, mammals only traded certain advantages for others, as did reptiles.