The phenomenon due to which a ray of light deviates from its path, at the surface of separation of two media, when the ray of light is travelling from one optical medium to another is called refraction.
Light bends while travelling from one medium to another as its velocity differs from one medium to another. The speed of light in optically rarer medium is larger compared to that in optically denser medium. Hence, while travelling from one medium to another, light bends and refraction occurs.