This phenomenon is called refraction, which is the bending of light as it passes from one medium to another. Air is optically less dense (rarer) than glass, which is optically denser. When light enters an optically denser medium from an optically rarer medium, it slows down. This decrease in speed causes the light ray to bend towards the normal line (an imaginary line perpendicular to the surface at the point of incidence). Conversely, when light goes from a denser medium to a rarer medium, it speeds up and bends away from the normal.