How far down the rabbit hole are we going?
Short answer: refraction is caused by the response of the material to the impinging EM wave.
Longer answer:
As an EM wave enters a material, it interacts with it. The electrical part re-orients the electrical dipoles and the magnetic part re-orients the magnetic dipoles. The material re-orients, stretches, or whatever it does in response, adding it's own polarity to the wave, enhancing it, but slowing it and diminishing it as the material response time becomes a factor. We boil all these effects into the complex numbers of permittivity (loosely known as the dielectric constant, strictly, the dielectric constant is the real part of permittivity) and permeability.
Separately, scientists have observed the familiar "light bending" phenomenon, and developed an empirical shorthand called "index of refraction" that was just a geometric ratio. However, the linkage between this simple geometric coefficient and the underlying physics above turns out to be marvelously elegant.
The refractive index is the square root of the product of permittivity of and permittivity. At optical frequencies (*cough* wavelengths, sorry, sounded like an EE there) the relative permeability is nearly always 1, and in clearish materials, the imaginary part of the permittivity is very very small, so the index refraction is usually just the square root of the dielectric constant.
Cool, eh?