Because when light enters a new substance, its speed changes. In order for the law demonstrated in the equation (frequency = speed/wavelength) to remain the same, the wavelength of the light particle/wave must shorten or lengthen. This change causes the wave to slightly refract to one side or the other.