Sunlight passing through raindrops causes rainbows via a process called refraction, which is the bending of light as it passes from one medium to another. This is analagous to pushing a shopping cart at the edge of a parking lot: if the wheels on one side roll off the pavement onto an adjacent area of grass, the cart will start to turn toward the grass. This is because the wheels moving on the pavement are able to roll faster than the wheels on the grass.
In the case of a rainbow, when sunlight hits a raindrop it does not move as fast through the water as it does through the atmosphere, so it bends a little. The light then turns again as it moves out of the raindrop and back into the air at its original speed. When light hits the rain at just the right angle, it is refracted through a raindrop and into our eyes, causing us to see a rainbow.
But how does the "white" sunlight produce a multicolored rainbow? Sunlight, or "white" light, is actually made up of continuous bands of different colored light--red, orange, yellow, green, blue, indigo and violet. Each color has a different wavelength, or frequency, which refracts slightly differently when it passes from one medium to another. As a result, white light can be broken up into its component colors by being passed through certain medium. For example, a prism can also create rainbows because the glass, like the raindrop, bends the different colors of light at slightly different angles.
Longer wavelengths are bent at larger angles, so longer wavelengths are bent less than shorter wavelengths. When sunlight hits a raindrop, the red light waves are bent at an angle of 42 degrees from their original direction from the sun. Shorter violet light waves are only bent at an angle of 40 degrees. The other colored light frequencies are bent at angles in between these two. This is why we see rainbows as a continuous band of colors with red on top and violet on the bottom.
A typical raindrop is also spherical and therefore its effect on sunlight is symmetrical about an imagined axis connecting the center of the drop and the sun. Because of this symmetry, so long as the raindrop is viewed along a line of sight that makes a 40- to 42-degree angle with the direction of the sun, the various colors of light will be visible. Thus, a rainbow is actually a circle centered on the point directly opposite the sun from the observer--the so-called antisolar point--with an angular radius of 42 degrees.
We don't actually see the full circle because the earth gets in the way. The closer the sun is to the horizon, the more of the circle we see. Right at sunset, we would see a full semicircle of a rainbow with the top of the arch 42 degrees above the horizon. The higher the sun is in the sky, the less of a rainbow is visible above the horizon.