Rainbows are just one of a wide variety of optical effects caused by the interactions between sunlight and various atmospheric conditions. Sunlight is actually a mix of every wavelength, or color, of the visible light portion of the electromagnetic spectrum.
As sunlight enters a raindrop, it slows down since water is more dense than air. This bends the light inside the drop. After it is bent, the light then reflects off the inside of the drop and finally exits. During this process, the light is broken into its component colors, giving us the rainbows we know and love.
A double rainbow occurs when the light is reflected twice inside the raindrop. Because it is reflected twice, the colors in the secondary rainbow are flipped with red on the bottom and violet on the top.