Einstein's primary motivation came from reading Lorentz's 1904 paper, "Electromagnetic Phenomena in a System Moving with any Velocity less than that of Light", which contains the Lorentz transformation and length contraction equations, and asserted the undetectability of "ether": "It will therefore be impossible to detect the influence of the Earth's motion on any optical experiment". He also was motivated by Poincare's 1904 "Sur la dynamique de l'electron", who stressed the subtleties of synchronizing clocks by speed-of-light signals and the idea of "local time" (time seeming to be dilated), and concluded that it was "as though" the ether didn't exist. Einstein's 1905 paper "On the Electrodynamics of Moving Bodies" borrowed their equations, adding the concept of relativity of simultaneity, explicit time dilation, velocity addition formula, and rejection of "ether".
Lorentz and Poincare were motivated by the experiments of Michelson-Morley and Trouton-Noble; and the work of Fitzgerald, Voigt, Rayleigh and Brace, and many others, who figured out most of the basic concepts between 1882 and 1900, starting from Maxwell's equations. Unlike Einstein, none of these physicists dreamed about riding on a light beam.