For a long time in physics, there had been a debate about the nature of light. Is light a particle or a wave? Nowadays, we know that it's both, but that's another story. In Einstein's time, light was primarily thought of as a wave due to the discovery of Maxwell's equations.
Maxwell's equations are a bit advanced to go over for my purposes, but all you need to know is that they completely describe the behavior of electric and magnetic fields. Electric fields affect magnetic fields, which affect electric fields, and so forth. To gloss over all the math, this feedback loop creates an electromagnetic wave that moves at the speed 2.998 x 108 meters per second. This number matched the speed of light so well that Maxwell correctly guessed that light is made of electromagnetic waves.
At the same time, there was something very odd about Maxwell's equations. In classical mechanics, all velocities are relative. We cannot feel the Earth moving beneath us because we're moving at the same speed. We cannot feel the Earth's orbit because we orbit along with it. We cannot feel our solar system's orbit around our galaxy, or our galaxy's motion through the cosmos. If the entire universe was moving in one direction, we could never know, since we move along with it. Maxwell's equations predict a specific velocity for light, but a velocity relative to what?
At first, scientists postulated that light was moving with respect to something called the luminiferous aether (nice sci-fi name there), also just called ether. The ether is supposed to be a medium for light waves the same way that the ocean is a medium for ocean waves. The ether would operate on light similarly to how wind operates on sound. Light would move faster when moving in the same direction as the ether, and slower when moving in the opposite direction. Since the earth cannot possibly be staying still with respect to the ether (since for one thing, it rotates), scientists predicted that light would move faster in some directions than in others. The famous experiment to test this was called the Michelson-Morley experiment, which involved putting two light sources on a rotating table. The experiment failed spectacularly, showing that light moves at the exact same speed in all directions.
In science, a failed experiment only provides new opportunities. To Einstein, the Michelson-Morley experiment showed that we must discard the concept of ether, along with many other things from classical physics. Einstein found that the speed derived from Maxwell's equations is very special in that there is no need to specify a reference frame. The speed of light is the same no matter which way you are going.