Sean Carroll in Quanta:
The development of relativity is usually attributed to Albert Einstein, but he provided the capstone for a theoretical edifice that had been under construction since James Clerk Maxwell unified electricity and magnetism into a single theory of electromagnetism in the 1860s. Maxwell’s theory explained what light is — an oscillating wave in electromagnetic fields — and seemed to attach a special significance to the speed at which light travels. The idea of a field existing all by itself wasn’t completely intuitive to scientists at the time, and it was natural to wonder what was actually “waving” in a light wave.
Various physicists investigated the possibility that light propagated through a medium they dubbed the luminiferous ether. But nobody could find evidence for any such ether, so they were forced to invent increasingly complicated reasons why this substance should be undetectable. Einstein’s contribution in 1905 was to point out that the ether had become completely unnecessary, and that we could better understand the laws of physics without it. All we had to do was accept a completely new conception of space and time.
More here.