To the naked eye, sunlight appears to be white. However, this white light is in reality made up of a combination of all the colors in the spectrum - red, orange, yellow, green, blue, indigo, and violet. Each of these colors has it's own wavelength, and the rays making up the white light can be bent and refracted so that they separate into the different colors of the spectrum.
http://www.cs.princeton.edu/~rywang/berkeley/singles/rainbows/recollection.html
This is what happens when a rainbow is formed. The light rays are refracted as they enter a droplet of water, inside the droplet they reflect off the far side of it and are further refracted as they leave. The rays are returned at an angle of about 42 degrees. The order of the colors of the rainbow are in order of decreasing wavelength; with red on top, followed by orange, yellow, green, blue, indigo, and violet.