Answer and Explanation:
The light that comes from the sun is called white light. Actually white light is a mixture of lights of different colors. When we look at the rainbow we can see the colors that make up the white light. This phenomenon, known as dispersion, occurs when a ray of composite light is refracted (refraction) in some medium, and its constituent colors are separated.
I attached you I picture where you can see this process
Basically, when the light passes through a glass prism, the different wavelengths that make up the beam of light travel inside it at different speeds and curl differently when entering and leaving resulting in a beam deviated from the initial direction and with its separate components.