As seen in the animation below, sunlight is refracted as it enters the raindrop. The different wavelenghts (colors) of the visible light spread out because of this refraction, similar to the bending of light by a glass prism. As with the prism, red light is bent the least and violet light the most.
Much of this refracted light passes right through the drop and goes unseen by the observer's eye. However, some of the sunlight strikes the back of a droplet at such an angle that it is reflected within the droplet. This occurs at the
critical angle.
If light strikes the back of a drop at an angle greater than the critical angle, it will be reflected back into the drop.
When the internally reflected light leaves the raindrop, it is refracted once again. Violet light (bending the most) emerges at an angle of 40 degrees relative to the incoming sunlight that has yet to undergo internal reflection, while red light (least bending) exits the drop with an angle of 42 degrees (see picture below). Other colors of the rainbow leave the raindrops at an angle somewhere in between.

Since we see only one color of light that is reflected from each raindrop (see section on Primary Rainbows for more details), it is no wonder that it requires an incredible number of raindrops to produce the magnificient spectrum of colors that are characteristic of a primary rainbow.