The rainbow creation is due to moisture. During the monsoons, especially after a storm, when the sun is on the backside, a rainbow is sometimes formed in the front.
To make the explanation a little easier, assume that there are fine raindrops floating in the air.
They act as a prism for white sunlight.
The natural light of the sun is made up of seven colors. All have a different wavelength. Red has a maximum (0.0007 mm), while violet has a minimum (0.0004 mm).
As they enter the droplets, they refract according to their respective wavelength; first, they are reflected by the inner surface of the droplets, and then refract again at the time of exit. In short, the refractive index is not the same for different colored rays.
The red rays form an angle of 42 degrees at the end, while the angle of the rest of the rays is less according to their successively shorter wavelengths. (see the picture below)
As a result, the top band in the rainbow appears red, while the rest of the bands become different colors until violet.
The condition for the appearance of different colors is that the only geometry that forms the angle that makes them visible is circular in shape, so the rainbow always appears in a circle.
An interesting thing to note: The rainbow that a person sees from a certain place does not appear the same to another person close to him, the rainbow appears to another person is completely different.
This is because the direct rays that come into the eyes are different from the point of view of the person. If the two changes their position, they will see each other's rainbow.