This is a very incomplete answer, but it should put you on the right road. I'm going to assume that you buy the usual argument for why a change in the speed of light generates a bend at the interface and concentrate on the speed of light in a medium.
We start with Maxwell's Equations (expressed here in the differential form and in SI units):
$$ \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0} \tag{Gauss}$$
$$ \nabla \cdot \mathbf{B} = 0 \tag{Gauss-magnetism}$$
$$ \nabla \times \mathbf{E} = \frac{\partial \mathbf{B}}{\partial t} \tag{Faraday}$$
$$ \nabla \times \mathbf{B} = \mu_0 \left( \mathbf{J} + \epsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right) \tag{Ampere-Maxwell} \,.$$
Notice in Gauss's Law and Ampere's Law the presence of the permittivity of free space $\epsilon_0$ and the permeability of free space $\mu_0$. When you manipulate Maxwell's Equations in a charge and current free region to get the wave equation those constants combine to give the speed of the wave as
$$ c = \frac{1}{\sqrt{\mu_0\epsilon_0}} \,.$$
Now, if we are considering a material environment we are no longer in a charge free region. The net charge is zero, but on a microscopic scale the protons and electrons are separated from each other, so there are sources and sinks for the electric field; moreover, the electrons are in motion (nuclei too, but we'll ignore that) so there are sources of curl in the magnetic field.
You might imagine that the effects of all of this on a traveling electromagnetic ware are pretty complicated, but the surprise is that in many cases1 we can group the effects by changing the constants2 to $\epsilon = \kappa \epsilon_0$ and $\mu = (\chi_m +1)\mu_0$ and otherwise pretending that we are still in a charge and current free region.3 Showing this is a rather longer development than I have room or time for here. See any upper-division or graduate E&M text.
Both of these new constants are larger than the ones they replace4, which means that when we construct the wave equation we have a new velocity
$$ v = \frac{1}{\sqrt{\mu \epsilon}} < c \,.$$
1 Sufficiently weak fields and sufficiently smooth materials, but these conditions include essentially every everyday case.
2 Strictly speaking these new values are frequency dependent $\epsilon_0(f) = \kappa(f) \epsilon_0$ ..., but in this simple discussion I'm going to ignore that. However, this frequency dependence is responsible for the frequency dependence of the index of refraction, which leads to observable phenomena.
3 Here $\kappa$ is the dielectric constant of the material and $\chi_m$ is it's magnetic susceptibility.
4 For normal materials. Work on exotic materials where that statement is too broad is a on-going field of research.