Why does the violet color appear on the inside of the rainbow? And, why does the red color appear on the outside of the rainbow?
Rainbows are formed because of the two optical phenomena: refraction and dispersion. Refraction is the bending of light when it passes the boundary between the two media, for example, air and water. The light refracts (changes the direction of propagation) as it enters a droplet of water, and then refracts again as it exists the droplet. The angle of refraction is determined by a number called the index of refraction.
Sometimes, as in the case of water, the index of refraction of the medium depends on the frequency of incident light. This phenomenon is called dispersion. It results in the light of different frequencies (that is, different colors) refracted under different angles. Because of this, the red light exiting a droplet makes a wider angle with the incident line than the blue or violet light.
As the observer on the ground looks at the sky after a rain, he or she "catches" only the rays of red light coming out of the droplets that are higher up, as the rays of violet light pass over his/her head. He also "catches" the rays of violet light coming out of the droplets that are lower down, as the rays of the red light are under his/her line of sight. Therefore, the observer sees the arc of violet on the bottom, the red on top, and the other colors in between.
Please see the reference link for the illustration and a more detailed description of the rainbow formation.