Refraction is the bending of light as it changes speed passing between media. The refractive index is $n = \dfrac{c}{v}$, and Snell's law relates the angles: $n_1 \sin i = n_2 \sin r$. Light bends towards the normal entering a denser medium and away entering a rarer one.
From a denser to a rarer medium, if the angle of incidence exceeds the critical angle $i_c$, all light is reflected — total internal reflection (TIR), with $\sin i_c = \dfrac{1}{n}$. TIR underlies optical fibres, diamond brilliance and reflecting prisms.
Refraction at a spherical surface gives $\dfrac{n_2}{v} - \dfrac{n_1}{u} = \dfrac{n_2 - n_1}{R}$. Applying this at both surfaces of a thin lens yields the lens maker's formula $\dfrac{1}{f} = (n-1)\left(\dfrac{1}{R_1} - \dfrac{1}{R_2}\right)$. The thin lens formula $\dfrac{1}{v} - \dfrac{1}{u} = \dfrac{1}{f}$ locates the image, with magnification $m = \dfrac{v}{u}$. A converging (convex) lens has $f > 0$, a diverging (concave) lens $f < 0$. The power is $P = \dfrac{1}{f\,(\text{m})}$ in dioptres, and lenses in contact add: $P = P_1 + P_2$.
A prism deviates a ray by $\delta$, which is minimum ($\delta_m$) when the ray passes symmetrically. Then $n = \dfrac{\sin\frac{A + \delta_m}{2}}{\sin\frac{A}{2}}$, where $A$ is the refracting angle. Since $n$ varies with wavelength (dispersion), white light splits into a spectrum — violet deviating most, red least.
Optical instruments enlarge the visual angle. A simple microscope gives $M = 1 + \dfrac{D}{f}$ ($D = 25\,\text{cm}$). A compound microscope uses an objective and eyepiece, $M \approx \dfrac{L}{f_o}\cdot\dfrac{D}{f_e}$. An astronomical telescope in normal adjustment has $M = \dfrac{f_o}{f_e}$ and tube length $L = f_o + f_e$; a large objective and small eyepiece focal length give high magnification and a bright image.