The area lining the inner surface of the eyeball is known as the retina. There are different types of photoreceptor cells called rods and cones located there. The cones are for color vision primarily used during the day and the rods are for black and white vision mainly at night. When the stimulus of light is collected by the eye, the image forms on the retina and then the cells of the retina will trigger a nerve impulse which travels through the optic nerve to the vision area of the cerebrum in the brain. Sometimes the retina is compared to film inside a camera. There are 7 million cones and 75-150 million rods in the retina.
Humans, along with apes, and a considerable number of Old World monkeys are trichromatic, which literally means "three colors," having three different kinds of opsins (light sensitive protein pigments) on their cones. These allow visual discrimination between blues, greens, and reds. However, a genetic defect known as achromatopsia causes defective cones and results in no color vision perception.
Among primates, trichromacy appears to have evolved as it gives the possessor an advantage in determining ripe from unripe fruit. Additionally, the ability to see red would aid in finding fruit in an all-green vegetation background.
Red-green colorblindness ("deuteranomaly") affects about 6-8% of the population. However, although this may be a defect when determining the ripeness of fruit, it allows the possessor an advantage in discriminating between khaki colors, which could have been useful in grassland environments to see predators.
For an excellent detailed description, see the link: