The story begins over 55 million years ago, after angiosperm forests spread across the earth during the late Cretaceous (94 million to 64 million years ago). At that time, some small, insect-eating mammal, which may have resembled a tree shrew, climbed into the trees, presumably in search of pollen-distributing insects. But its descendants came to rely substantially on edible plant parts from the canopy, a change that set the stage for the emergence of the primate order.
Natural selection strongly favors traits that enhance the efficiency of foraging. Hence, as plant foods assumed increasing importance over evolutionary time (thousands, indeed millions, of years), selection gradually gave rise to the suite of traits now regarded as characteristic of primates. Most of these traits facilitate movement and foraging in trees. For instance, selection yielded hands well suited for grasping slender branches and manipulating found delicacies.
https://www.scientificamerican.com/article/diet-and-primate-evolution-2006-06/