Light refracts when it passes through the boundary of two dissimilar materials because the speed and wavelength of light changes in different media. Light does not refract when crossing between two media of identical refractive indicies, or when it falls perpendicular to the interface.
The refraction of light from a medium where it travels faster to a medium where it travels slower is in the direction of the normal to the interface. This form of refraction occurs when light travels from air to water or glass because it is faster in the former than the latter. Light traveling from a slower medium to a faster one refracts away from the normal to the interface. The degree of refraction from the slower medium to the faster one is equal and opposite to the refraction from the faster to the slower one. The degree of refraction between two media is quantified by their respective indices of refraction. As the value of the relative refractive index between two media increases, the degree of refraction of a light ray crossing the interface between the two media also increases. Light refraction is governed by Snell’s Law, which states that the refractive indices between two media is proportional to the inverse of the sines of the incident and emergent angles of a light ray relative to the normal.