Refraction - Function
Refraction is the bending of light (or any wave) when it passes from one medium to another
When light moves from air into water or glass, it changes speed and bends at the boundary. This bending is called refraction.

This is refracted ray in the drawing, the light refracts in the point of contact with water
There is other possibility for the light wave is to reflect off
The third possibility of light is to get absorbed
Refraction Logics
Light travels at different speeds in different media.
It slows down in denser materials (like glass or water) and speeds up in less dense ones (like air).
Light travels fastest in vacuum
Refractive Index
Refractive index is the ratio of the speeds of a light wave in two different media
Formula = Sin i / Sin r