Special Relativity can be motivated by looking at Maxwell's Electrodynamics and noticing that there is some kind of inconsistency between it and Newtonian Mechanics. Indeed, as Einstein pointed out on his paper the major two issues are:
There are many electromagnetic phenomena where what really matters is the relative motion between two observers. What happens here is that if each observer tries to apply the laws of electrodynamics, each of them will arrive at different descriptions, whereas the observed phenomena will be the same. This suggests that somehow, the same frames on which the laws of mechanics hold in the same form should be the ones on which the laws of electrodynamics holds in the same form.
The electric and magnetic fields were thought to be stresses on a specific material medium called the luminiferous aether. More than that, it was believed that the laws of electrodynamics should hold with respect to the aether frame inasmuch as light had speed $c$ relative to its propagation medium, which again would be the aether. Now, at time Einstein proposed the theory, there had been a quite reasonable number of failures in detecting this medium and its frame of reference. This would imply that there was no absolute frame to formulate the laws of electrodynamics.
Those are the main motivations of the theory. There is one quite subtle point, though, that I always wanted to understand better: when Einstein proposed the theory in his well-known article, he stated the motivation and then stated the postulates. But what when we purpose those postulates, what is really being sought?
I mean, what Einstein was really looking for was a new way to transform between reference frames that would keep the laws of electrodynamics invariant inasmuch as the Galilean transformations keep the laws of Newton invariant?
In that sense, what Einstein saw was that the principle of relativity from Galileo should work for electrodynamics, but in the form it was written it couldn't work, because there was one supposition of absolute time. In that sense, Einstein rederived the transformations based on that principle without absolute time to make it work for the laws of electrodynamics? So in the end, the first objective was to arrive at the Lorentz transformations?