Why does the speed of light vary in different mediums even if light does not need a medium to travel?
I think you are confused between the two statements. The fact that light does not need a medium to travel is irrelevant of its speed. The reason why Light does not need any medium to travel is because it is an electromagnetic wave. As far as we know, any wave changes its speed in a different medium, be it mechanical or electromagnetic. Also, I think you are being a bit biased towards the properties of light. I mean, if any electromagnetic wave travels in some medium its wavelength and velocity are not only dependent on its own properties but also the medium's properties(Refractive index). Electromagnetic wave interacts with the matter in the medium. According to Maxwell, the velocity of an electromagnetic wave is given by:- [math]\mu\mu_0\varepsilon\varepsilon_0=1/v^2[/math] where [math]\mu\varepsilon[/math] are properties of the medium. Since they are absent in vacuum, we have [math]\mu\varepsilon =1[/math]. Now, if light is in no medium, it still has a speed which means it is moving thereby conforming that light needs no medium to travel. Hence, the formula proves that light changes its speed in any medium without contradicting the statement that "light does not need a medium to travel".