Rainbows are formed because of the refraction and dispersion of white light into colors of a different wavelength
Lightray enters the drop near its top level, at first refraction happens and then the dispersion.
Each color is refracted back into the drop due to complete internal reflection which hits the drop surface.
We can witness a rainbow when we see them between 42-20 degrees.