Rainbows occur when rain is falling in one part of the sky and the sun is shining in another. The geometry necessary for this process to be seen has sunlight coming from behind the observer. As it enters a raindrop the light is refracted, then it is reflected off the inside of the drop, which bends it back toward the observer. Finally, it is refracted again as it leaves the drop. This process separates light into its component colors, which we see with red at the top and violet at the bottom.
Rainbows also appear in the spray from a waterfall or sprinkler.
The arc of the rainbow is 42 degrees. On rarer occasions, a less intense secondary rainbow is visible with an arc of 50 degrees. These happen when the light is sufficiently strong to produce two refractions and two internal reflections. The colors are reversed on a secondary rainbow with violet being on the outside and red on the inside. We see only a partial arc of a rainbow because Earth gets in the way and blocks the light.