When we consider two media (such as air and glass), the medium with lower refractive index is called the optically rarer medium (in the present case, air) and the medium with higher refractive index is called the optically denser medium (glass, in the present case).
The higher density does not necessarily mean higher refractive index. For example, the density of water is greater than that of kerosene, but the absolute refractive index of water is less than that of kerosine. Thus, when we consider water and kerosine, water is an optically rarer medium while kerosine is an optically denser medium.
If we consider kerosene and benzene, kerosine is an optically rarer medium while benzene is an optically denser medium.