Walter Isaacson in Scientific American:
The general theory of relativity began with a sudden thought. It was late 1907, two years after the “miracle year” in which Albert Einstein had produced his special theory of relativity and his theory of light quanta, but he was still an examiner in the Swiss patent office. The physics world had not yet caught up with his genius. While sitting in his office in Bern, a thought “startled” him, he recalled: “If a person falls freely, he will not feel his own weight.” He would later call it “the happiest thought in my life.”
The tale of the falling man has become an iconic one, and in some accounts it actually involves a painter who fell from the roof of an apartment building near the patent office. Like other great tales of gravitational discovery—Galileo dropping objects from the Leaning Tower of Pisa and the apple falling on Isaac Newton's head—it was embellished in popular lore. Despite Einstein's propensity to focus on science rather than the “merely personal,” even he was not likely to watch a real human plunging off a roof and think of gravitational theory, much less call it the happiest thought in his life.
Einstein soon refined his thought experiment so that the falling man was in an enclosed chamber, such as an elevator, in free fall. In the chamber, he would feel weightless. Any objects he dropped would float alongside him. There would be no way for him to tell—no experiment he could do to determine—if the chamber was falling at an accelerated rate or was floating in a gravity-free region of outer space.
More here.