We speak of ordinary light as being “white” we call it white light, or sunlight. But this light is really a mixture of colors.
When sunlight strikes the beveled edge of a mirror, or the edge of a glass prism, or the surface of a soap bubble, we see the colors in the light. What happens is that the white light is broken up into the different wavelengths that are seen by our eyes as red, orange, yellow, green, blue, indigo and violet.
These wavelengths form a band of parallel stripes, each color grading into the one next to it. This band is called a “spectrum”. In the spectrum, the red line is always at one end and the indigo and violet lines at the other end, and this is decided by their different wavelengths.
When we see a rainbow, it is just as if we were looking at such a spectrum. In fact, a rainbow is simply a great curved spectrum caused by the breaking up of sunlight.
When sunlight enters a droplet of water, it is broken up just as if it had entered a glass prism. So inside the drop of water, we already have the different colors going from one side of the drop to the other. Some of this colored light is then reflected from the far side of the droplet, back and out of the droplet.
The light comes back out of the droplet in different directions, depending on the color. And when you look at these colors in a rainbow, you see them arranged with red at the top and violet at the bottom of the rainbow.
A rainbow is only seen during showers when rain is falling and the sun shining at the same time, but opposite sides of the observer. You have to be between the sun and the droplets of water with the sun at your back. The sun, your eye, and the center of the arc of the rainbow must all be in a straight line.