What is light?
White light is really composed of a mixture of all of the visible colors of light. Something about a rainbow treats the different frequencies differently and so that the white light is "broken up" into individual colors.
Speed and direction of light
The change in speed causes the direction of a light beam to change.
There is a relationship between the angles at which light enters and leaves a boundary between materials with different indices of refraction called Snell's law.