Light is a form of energy. It has properties like a wave. The energy of a light wave depends on its wavelength. For visible light, waves of different wavelengths are different colors. Blue light has a shorter wavelength than red light. Watch a podcast on light (Listening to Light)
WHAT MAKES THE COLORS?
Sunlight is made up of many colors of light, all combined together. When light goes from air to water (or glass), its direction changes a bit; its path is bent. Different colors are bent by different amounts. Blue light is bent more than red light. This dispersion causes the colors to separate from one another.
REFRACTION CHANGES THE DIRECTION OF WAVES
Think of the line of a marching band as part of a wave. When part of this band starts marching in the water, they slow down. The result is that they end up marching in a slightly different direction. Their path is bent. This is what happens to light when it passes from air to water. It is called refraction.
HOW WE SEE A RAINBOW?
When a ray of sunlight (A) enters a raindrop, its path is bent. It comes out in a different direction (B). At the same time, it is separated into multiple colors (not shown for B above). But part of the light also reflects off of the inside of the raindrop, and goes in direction C. As it exits the raindrop, the colors spread out even more. A person viewing this light sees it coming from the direction of the raindrop (not from the Sun!). This is how the primary rainbow is formed.
WHERE'S THE RAINBOW?
To see a rainbow, you need to have the Sun at your back. The ray of sunlight comes out of the raindrop at an angle of 42 degrees from the direction back to the Sun. That means you will see the primary rainbow 42 degrees above your shadow!