A rainbow is formed by the dispersion of sunlight by the raindrops in the atmosphere.
When the sunlight passes through the raindrops, it first gets refracted, then gets internally reflected, and then refracted again, leading to dispersion of sunlight, and the rainbow forms.
Hence, the rainbow is formed by the dispersion of light.