I've been told that the speed of light is invariant - that it is always the same, regardless of the frame of reference. Why is it that way? Is it a side-effect of time dilation and/or spacial contraction? Is it something else, possibly related to the fact that photons are massless?

You've got a couple of different concepts rolled into one there.

First is the idea that nothing can move faster than the speed of light. I'm not sure we can really answer

*why* that is. The idea came about, initially, by observation. If we give a particle X amount of energy and it goes half of the speed of light, we would expect (classically) that if we gave it 4X as much energy that it would go the speed of light. What we actually found is that 4X as much energy for maybe 80% of the speed of light, 100X got 99% the speed of light, 1000X got 99.9% of the speed of light, etc. Einstein explained this phenomenon by making the assumption that nothing could ever go faster than the speed of light. All of the effects such as time dilation fall out of the math that results from making this assumption.

The second concept is that the speed of light (in a vacuum) is the same at all times and places in the universe. There is nothing that I know of that strictly requires this to be true, but it certainly makes sense that it's so in terms of simplicity. Since the speed of light affects a great many phenomenon, there actually are quite a few tests we could perform to see if it has changed in the past. For example, since E=mc

^{2}, if the speed of light had been higher in the past, then if two electrons annihilated it would have produced higher energy gamma rays than the 511 keV ones we see today. Similarly, some atoms which are stable at our current speed of light would become unstable with a higher speed of light. To date, no effects like those have been observed.