Einstein's theory of special relativity explains (general relativity is broader, but SR is enough for now)
A fellow named James Clerk Maxwell came up with a bunch of equations that modeled the behavior of electromagnetic waves. One of the results of this model (which has been thoroughly checked) was that how fast a beam of light travels is the same for all observers, regardless of their motion. The only way this can be true (and it's been quite thoroughly tested, too) is if time and distance is not the same for these observers.
Using the Hyperphysics site: (
Concepts of Special Relativity)
1) Galileo had demonstrated that all motion is relative, leading to the Galileian Transform (
Lorentz Transformation) which works perfectly well at low speeds
2) Because of Maxwell, the speed of light must be the same for all observers (
Concepts of Special Relativity), leading to
3) the Lorentz transformation (
5.5 The Lorentz Transformation - University Physics Volume 3 | OpenStax) ensures that speed of light is the same for all observers