The Egyptian geographer Ptolemy who lived between 90 and 168AD tried to explain the phenomenon, but was not entirely successful.
however, the actual law of refraction was discovered in the early 1600s by a dutch mathematician Willebrord Snel Van Royen. He explained that when light travels from one medium to another, it generally bends, or refracts. The bending is caused by the differences in density between the two substances, which in turn affect the speed at which light travels through them. Snel's explanation of refraction is still known as 'Snell's law'.