>>11847148It didn't until the very last little bit of time, here's how it went down;
Mammal adapts to aboreal lifestyle, running around and climbing in trees, because fruit and nuts are excellent sources of food.
Mammal group diversifies and speciates into many specialized forms to take advantage of narrower niches in the forest ecosystem; some remain completely aboreal, some find success running around on the forest floor due to more advanced social structures etc. Most remain small, some get larger. All have evolved finger dexterity, because their ancestor was too heavy to rely on gripping via claws alone.
Dexterity gave smarter individuals a greater advantage because they could move while holding more food, making for snatch and grab tactics. It also allowed for increased grooming capability and the development of social grooming, further increasing social behaviors.
One group of these social mammals, with a larger body size and mostly ground-level lifestyle, found itself in the middle of a rapidly changing climate in Ethiopia. This species survived because the brainpower it did have allowed it to forage for more difficult to access foods over a wider area, requiring simple tool use, long term memory, and strong social bonds to maintain territories and social groups. After many generations of adapting to this new lifestyle, the advantages it gave this species became obvious as they were able to increase their range across much more land and into many new environments, continuing to evolve and become better and better at learning how to survive in new places.
The reason intelligence evolved was because of a climate change event that almost wiped out our ancestors, except for the very smartest ones who figured out how to dig up edible roots using sticks and how to steal kills from other predators.