

This is because the light ray bends only when travelling from the rarer medium (medium 1) to the denser medium (medium 2). As a result of this the refractive index is measured as the index of refraction (or bending of the light ray) in medium 2 to with respect to medium 1. Hence it is written as n21.
