I believe you are actually referring to refraction - the bending of light when it goes from one medium to another.
Light is a form of energy which travels as waves with a certain frequency, wavelength, and velocity. When a wave hits an interface (in your case when the wave goes from air into the glass) the velocity of the wave changes depending on the density of the substance.
When a wave strikes the interface from the normal, the wave front reaches the glass all at the same time. However, when the wave strikes the surface at an angle, part of the wave front enters the glass sooner than other parts of the wave. As each portion of the wave enters the glass it slows down in sequence and you get the bending effect that you see.
Diffraction is the slight bending of a wave as it goes around an object. (see second referrence link below)