Rainbows are formed when sunlight is refracted, reflected, and dispersed in water droplets in the atmosphere, such as in rain or mist. The water droplets act like prisms, separating the sunlight into its different colors. This dispersion of light creates the beautiful spectrum of colors that we see in a rainbow.