Total internal reflection is a strange phenomenon that happens when a propagating wave strikes a medium boundary at an angle larger than a particular critical angle with respect to the normal to the surface. If the refractive index is lower on the other side of the boundary and the incident angle is greater than the critical angle, the wave cannot pass through and is entirely reflected. The critical angle is the angle of incidence above which the total internal reflection occurs.
Hence, for total internal reflection to occur, the light should pass from a denser to a rarer medium.