Rainbow occurs when the light radiated from the sun. Comes into contact with water droplets in the atmosphere. So how does the light travel through the water droplets and create seven colored rainbow?
Rainbows appear in seven colors because of water droplets break sunlight into the seven color of the spectrum. We get the same result when sunlight passes through a prism. The water droplets in the atmosphere act as prism, through the traces of light are very complex.
When light ray meets a water droplet, it is refracted at the boundary of air and water and enters the droplet where the light is dispersed into seven colors. This rainbow effect occurs because the light is then reflected inside the droplet and finally refracted out again into the air.