Light changes direction when it crosses between materials in which it travels at different speeds. Snell’s law fixes exactly how much.
Both angles are measured from the normal — the line perpendicular to the surface — not from the surface itself. Getting this wrong is the most common error in refraction problems, and it turns a 30° answer into a 60° one.
Refractive index
The refractive index n is the ratio of light’s speed in vacuum to its speed in the material, so n = c/v. Water’s 1.33 means light travels at about 225,000 km/s inside it. Index is always at least 1 for ordinary materials, and a higher index means slower light and stronger bending.
Entering a denser medium bends light toward the normal; leaving into a thinner one bends it away. This is why a straw in a glass of water appears broken at the surface, and why a pool looks shallower than it is.
Total internal reflection
Going from dense to thin — glass to air, say — the refracted ray bends further from the normal as the incident angle grows. At some angle it would need to exceed 90°, which is impossible, so no light escapes at all. Everything reflects back inside.
For glass to air the critical angle is about 41°; for water to air, about 49°; for diamond to air, only 24°. Diamond’s unusually small critical angle traps light through many internal bounces before it escapes, which is the origin of its brilliance.
Optical fibre is total internal reflection put to work: light enters at a shallow angle and bounces along the core for kilometres with almost no loss, because at every bounce it exceeds the critical angle.
Dispersion
Refractive index depends slightly on wavelength — blue light is bent more than red. A single index, as used here, is an approximation for one colour. That small dependence is what splits white light into a spectrum through a prism, and it produces rainbows from raindrops. It is also a nuisance in lens design, where it causes chromatic aberration and has to be corrected with multiple glass types.