I was reading an article by Guenther Knoblich and Michael Oellinger of the same title of this post in the November/December 2006 issue of Scientific American Mind.
The opening paragraph is
Albert Einstein finally hit on the core idea underlying his famous theory of relativity one night after months of intense mathematical exercises. He had given himself a break from the work and let his imagination wander about the concepts of space and time. Various images that came to mind prompted him to try a thought experiment: If two bolts of lightning struck the front and back of a moving train at the same time, would an observer standing beside the track and an observer standing on the moving train see the strikes as simultaneous? ...
As a Physics students (I even named myself after Einstein), I am ashamed to admit that I have not read that original paper. Now with search so easily done on my desk, I googled and found the English translation of the paper: On the Electrodynamics of Moving Bodies. It was a delightful and satisfying reading.
During the search I also found an essay "'What Song the Syrens Sang': How Did Einstein Discover Special Relativity?" by John Stachel written in 1983.
How did Einstein's Eureka Moment occur?
The Eureka moment might have occurred, as described by Guenther Knoblich and Michael Oellinger in a night suddenly, but Einstein himself had said
"A new idea comes suddenly and in a rather intuitive way. That means it is not reached by conscious logical conclusions. But, thinking it through afterwards, you can always discover the reasons which have led you unconsciously to your guess and you will find a logical way to justify it. Intuition is nothing but the outcome of earlier intellectual experience."
The essay by John Stachel gave a good account of the earlier intellectual experience. The final Eureka moment might be [quoting John Stachel]:
[John Stachel] believe that the first principle, the relativity principle, recapitulates his struggles with the mechanical ether concept which led finally to the first crucial liberation of his thought - the abandonment of the ether. The second principle, the principle of the constancy of the speed of light, recapitulates his struggle, once he had definitely opted for the relativity principle, first to evade the Maxwell-Lorentz theory by an emission theory; then to isolate what was still valid in the Maxwell Lorentz theory after giving up the ether concept and abandoning absolute faith in the wave theory of light. The struggle to reconcile the two principles could only end successfully after the second great liberation of his thought: the relativisation of the concept of time.
As reported by Mark Jung-Beeman, Edward M. Bowden, Jason Haberman, Jennifer L. Frymiare, Stella Arambel-Liu, Richard Greenblatt, Paul J. Reber, John Kounios in
Neural Activity When People Solve Verbal Problems with Insight,
Functional magnetic resonance imaging [snip] revealed increased activity in the right hemisphere anterior superior temporal gyrus for insight relative to noninsight solutions. The same region was active during initial solving efforts. Scalp electroencephalogram recordings [snip] revealed a sudden burst of high-frequency (gamma-band) neural activity in the same area beginning 0.3 s prior to insight solutions. This right anterior temporal area is associated with making connections across distantly related information during comprehension. Although all problem solving relies on a largely shared cortical network, the sudden flash of insight occurs when solvers engage distinct neural and cognitive processes that allow them to see connections that previously eluded them.
Also as noted in the article in Scientific American Mind,
step by step problem solving took place mainly in the left hemisphere, through the conscious application of logical rules, which would rely on deliberate language. The right hemisphere, [snip] played a critical role in solving insight problems, which require restructuring - a spatial task. Individual would experience a eureka moment only when the right hemisphere sent the solution to the left hemisphere, thereby putting the solution into discernible terms.