A rainbow is formed when the light coming from the sun falls diagonally on the drop of water, and the light is reflected after passing through the inner surface of the water drop, then travels until it comes out again from the drop in the air, and is refracted again due to different media as well.