Rainbows occur as a result of sunlight being refracted and reflected by raindrops (or mist or spray).
To see a rainbow, you must have your back to the Sun and there must be sunlight as well as rain. The sunlight that strikes drops of rain is literally bent as it enters the liquid.
When sunlight bends, as when it shines through a prism, the light separates into the spectrum of colors: red, orange, yellow, green, blue, indigo, and violet.
The light bounces off the back walls of the raindrops and is bent again, mirroring the spherical shape of the water droplet in an arc, or bow.
The sunlight, the rain, and the observer’s line of sight must form an approximate 42° angle for a rainbow to be visible. It is at this angle that the reflected, refracted light can be seen. A double rainbow is the result of the water droplets being large enough that the sunlight reflects twice within the raindrop before becoming a rainbow. An angle of about 52° is needed for a double rainbow.
When sunlight hits water droplets at a certain angle, we see a rainbow. The droplets separate the sunlight into the different colors of the visible spectrum, just like a prism does.