The advantages of color vision in frugivorous, arboreal mammals is obvious, color vision enables one to be able to easily distinguish between the innumerable different varieties of fruit found in the forest canopies, but how exactly did it evolve? In order to solve this riddle inside a mystery wrapped in an enigma, we must turn to genetics for help. According to Wilderman et al (2011), the evolution of color vision in primates may have ultimately been due to the need to detect skin flushing, which makes a certain kind of sense since most primates are social creatures, but there is also evidence that indicates that the evolution of trichromatic color vision in primates had to due with the need to tell red fruit apart from green and blue fruit.
Since primates tend to be social creatures, there is some credence towards Wilderman's hypothesis, but there are perhaps other reasons for the evolution of color vision in primates other than the two already mentioned. One theory is that it had something to do with the evolution of olfactory systems. There is also some credence towards this hypothesis, since one can tell that most simian's olfactory systems are shit, including (and especially, from our POV) humans, and the evolution of highly advanced color vision in anthropoid primates may have been due to the need to compensate for the shit olfactory systems anthropoid primates tend to possess. Note that these reasons aren't mutually exclusive, the evolution of color vision may have had to do with all three of these reasons, and given the fact that primates tend to be social creatures who are also omnivorous with a tendency to lean towards frugivory, and most "ancestral" primates are also arboreal, as even we have some vestiges of our arboreal roots (one can't help but notice that humans tend to be pretty good at climbing trees), I believe that the origin of color vision in primates had to do with all three of these reasons.