Well, the explanation always goes like the speed of light decreases as it travels from a less dense into a denser medium.
But yet, so what if the speed decrease, what has it got to do with bending?
this picture below from wikipedia sums it all up nicely
notice that light, which is an electromagnetic wave, actually moves slower compared to the parts of the same wave in the less dense region by bending. (this effect is shown by the red line)