Albert Einstein begins to apply laws of gravity to Theory of Relativity

In 1907, while still working at the patent office, Einstein had what he would call his "happiest thought". He realized that the principle of relativity could be extended to gravitational fields.

He thought about the case of a uniformly accelerated box not in a gravitational field, and noted that it would be indistinguishable from a box sitting still in an unchanging gravitational field. He used special relativity to see that the rate of clocks at the top of a box accelerating upward would be faster than the rate of clocks at the bottom. He concludes that the rates of clocks depend on their position in a gravitational field, and that the difference in rate is proportional to the gravitational potential to first approximation.
Although this approximation is crude, it allowed him to calculate the deflection of light by gravity, and show that it is nonzero. This gave him confidence that the scalar theory of gravity proposed by Gunnar Nordström was incorrect. But the actual value for the deflection that he calculated was too small by a factor of two, because the approximation he used doesn’t work well for things moving at near the speed of light. When Einstein finished the full theory of general relativity, he would rectify this error, and predict the correct amount of light deflection by the sun.
From Prague, Einstein published a paper about the effects of gravity on light, specifically the gravitational redshift and the gravitational deflection of light. The paper challenged astronomers to detect the deflection during a solar eclipse. German astronomer Erwin Finlay-Freundlich publicized Einstein’s challenge to scientists around the world.

In 1907, two years after proposing the special theory of relativity, Einstein was preparing a review of special relativity when he suddenly wondered how Newtonian gravitation would have to be modified to fit in with special relativity. At this point there occurred to Einstein, described by him as the happiest thought of my life , namely that an observer who is falling from the roof of a house experiences no gravitational field. He proposed the Equivalence Principle as a consequence:-

... we shall therefore assume the complete physical equivalence of a gravitational field and the corresponding acceleration of the reference frame. This assumption extends the principle of relativity to the case of uniformly accelerated motion of the reference frame.

After the major step of the equivalence principle in 1907, Einstein published nothing further on gravitation until 1911. Then he realised that the bending of light in a gravitational field, which he knew in 1907 was a consequence of the equivalence principle, could be checked with astronomical observations. He had only thought in 1907 in terms of terrestrial observations where there seemed little chance of experimental verification. Also discussed at this time is the gravitational redshift, light leaving a massive body will be shifted towards the red by the energy loss of escaping the gravitational field.

... we shall therefore assume the complete physical equivalence of a gravitational field and the corresponding acceleration of the reference frame. This assumption extends the principle of relativity to the case of uniformly accelerated motion of the reference frame.”

It was in 1907 that Einstein began seriously to look into the problem of gravity. Two years after putting forward the special theory of relativity, he was sitting in his patent office in Berne wondering what would have to be done to Newtonian gravitation to make it fit in with his newly-hatched theory. Suddenly, he recalled, he had "the happiest thought" of his life:
[F]or an observer falling freely from the roof of a house there exists – at least in his immediate surroundings – no gravitational field. Indeed if the observer drops some bodies then these remain to him in a state of rest or uniform motion... The observer therefore has the right to interpret his state as 'at rest' [at least until he hits the ground!].
To drive home this point, imagine a slightly different situation. You're in a windowless room and are told that one of two circumstances is true: either the room is floating in space far away from any source of gravity or it's an elevator whose cable has been cut. Your task is to decide which, without leaving the room or otherwise obtaining information from outside. According to Einstein the task is impossible because there's no experiment you can carry out that will help you decide between the two scenarios. Nor, for the same reason, could you tell whether you were in a room that was sitting on the Earth or being smoothly accelerated at 9.8 meters per second per second – the rate at which things fall freely in Earth's gravity – by a rocket.

There's simply no observable difference, Einstein realized, between acceleration and gravity. On some deep level, they're one and the same. Consequently, he said:
[W]e shall ... assume the complete physical equivalence of a gravitational field and the corresponding acceleration of the reference frame. This assumption extends the principle of relativity to the case of uniformly accelerated motion of the reference frame.
It's an assumption that broadens the equivalence principle introduced by Galileo, which asserts that all objects fall at the same rate, with the result that mass measured gravitationally is indistinguishable from mass measured by its inertia. What's now called the Einstein or strong equivalence goes beyond this older, weaker version by stating that all the laws of physics, not just the law of gravity, are the same in all small regions of space, regardless of their relative motion or acceleration.

In the same year, 1907, that Einstein announced this broader principle of equivalence, he also began linking his mass-energy relationship, E = mc2, with gravity. It had long been known that gravity acts on everything with mass. Now that mass and energy turned out to be two sides of the same coin, it seemed reasonable to Einstein that gravity could act on energy too. In particular, it ought to be able to influence the movement of light rays.

Einstein's very first scientific paper, published in March 1905, had been on the nature of light. In it, he argued that a well known phenomenon in physics called the photoelectric effect could be explained if light behaved as if it consisted of tiny discrete particles. Later, these particles came to be known as photons. Because photons contained energy, and therefore, from the E = mc2 relation, an equivalent mass, their paths ought to be bent by gravity, just as the path of a bullet is curved by gravity as it travels from gun to target. But in 1907, when Einstein realized this, he was thinking only in terms of how light might be influenced by gravity here on Earth and there seemed little chance of experimentally verifying an effect that would be so small.