The law of refraction states that electromagnetic waves passing from one medium into another of a differing index of refraction will be bent in their direction of travel. Air and glass have different indices of refraction. Therefore, the path of electromagnetic waves moving from air to glass at an angle will be bent toward the perpendicular as they travel into the glass. Likewise, the path will be bent to the same extent away from the perpendicular when they exit the other side of glass. Refraction is responsible for many useful devices which bend light in carefully determined ways, from eyeglasses to telescope lenses.
Refraction also causes illusions.
This pencil appears to be discontinuous at the boundary of air and water. Spacecraft may appear to be in different locations in the sky than they really are. Electromagnetic waves entering Earth's atmosphere from space are bent by refraction. Atmospheric refraction is greatest for signals near the horizon where they come in at the lowest angle, and the apparent altitude of the signal appears to be on the order of half a degree higher than its true height. Refraction's effect on the sun adds about 5 minutes of time to the daylight at equatorial latitudes, since it appears higher in the sky than it actually is.