In order for any rainbow to appear, the right weather conditions must be met. As we have all been able to verify, we do not see the rainbow every time it rains, especially in stormy or windy conditions. There must be rain in suspension so that the balls of the raindrops are as circular as possible. There has to be a low sunlight angle; it cannot be at the zenith and, logically, we have to be in the right position.
But what happens when a ray of sunlight hits one of those droplets of water suspended in the atmosphere? As we already know, the sunlight is transmitted in a straight line as long as it does not change the medium in which it is traveling, when it encounters the water balls it changes the medium so it has to change its direction. That is called refraction of light. And not only changes the direction but, depending on the color, it deviates in a different way; this is called dispersion of light.
The angle of deviation that light undergoes when it enters the water drop is lower for the red light, maximum for the violet light, and intermediate for the rest of colors that make up the white light. It is the same thing that happens in a prism.
Once the ray of light is inside the little ball of water, it crosses the diameter of the drop and meets the other side, which returns to give vent to the air. Part of that light does not come out of the ball but it stays inside the water ball. This is what is called internal reflection.
Since light is already separated by colors, the angle of reflection is slightly different also for each color. When it comes back again, it finds the face it had entered the first time and changes its direction again by going backward (it refracts again). In short, it comes out on the same side where it had entered but at a very different angle, between 138 and 140 degrees from the initial direction. And for us, since we must be between the sunlight and the floating raindrops to see the rainbow, that angle is approximately 40 degrees.
To understand why we see an arc, we have to think about what geometric figure describes 40 degrees, giving us a kind of vertex; that figure is a cone. From where we are, left, right, up and, obviously not down because the ground is, those 40 degrees of opening form a cone. If the floor were not there, we would see a complete circle. But as the floor is what we see as part of the cone, then we have the optical illusion of seeing an arch; the rainbow.
But, in some special circumstances, it is possible to see the full circle. For example, from an airplane, it can be seen when the water curtain is below. Then there is no floor and the arch closes completely. There are also very nice pictures of the full circle made from skyscrapers, when the proper angle of the sun is produced and the water curtain is lower than the place from which the photo is being taken.
There are times that we can see a 2nd rainbow above the 1st one. What is the reason for this 2nd rainbow? We should remember that when light enters, it suffers a 1st refraction in the face of the raindrop that it crosses; suffers a reflection on the opposite side, turns back, and leaves the water drop with a 2nd refraction.
In order for the 2nd rainbow to occur, it must remain inside the drop after the 1st reflection, re-reflect for the 2nd time, and exit the 3rd time it collides with the separation wall between the water and the air. That exit angle is a little larger, around 50 degrees to us, so we see it above the other.
This 2nd bow looks very little because it has had to be reflected twice and, therefore, it has lost light along the way, which is why it is more tenuous. In addition, it has the characteristic that those colors are inverted. That is why that, in the 2nd reflection within the water droplet, the different colors have been inverted and violet appears above and red appears below.