When light (or other electromagnetic waves) pass into denser mediums the waves find it harder to move and they slow down.
This results in a change of direction unless the waves hit the surface along a Normal (i.e. at 90° to the surface):
Angle i is the angle of incidence (just like in reflection). Angle r is the angle of refraction.