Rainbows are formed when sunlight is refracted, reflected, and dispersed in water droplets in the atmosphere, such as rain. This refraction and reflection process results in the separation of sunlight into its different colors, creating the beautiful arc of colors that we see in the sky.