Light bends when it changes medium because its speed changes. Snell's law gives the bending angle.
Light slows down in denser media (glass, water). When the wavefront enters at an angle, one side slows before the other — so the ray pivots, like a trolley wheel hitting mud.
Snell's law sin θᵢ = n · sin θₜ — light entering a denser medium bends toward the normal and slows down. (Going the other way, past a critical angle it can't escape at all — total internal reflection, the trick behind fibre optics.)
n is the refractive index, n = c / v. Larger n ⇒ slower light ⇒ ray bends more toward the normal on entry.
Light goes from air (n = 1.00) into water (n = 1.33) at 40° from the normal. What's the angle inside the water?
Refraction is why a straw looks bent in a glass of water, why pools look shallower than they are, and why a prism splits white light — each colour bends a slightly different amount.