Isn't the point of the Death Star that you can use its lasers to destroy any planet or capital ship nearby? Then how could the Empire use the Death Star if it has to stay close to Endor at all times, because its shield generator is there? It seems that the Rebels just need to wait for the Death Star to move away from Endor and render itself vulnerable.
The shield generator was temporary protection while the second Death Star was under construction.
Both Death Stars had built-in shield generators to protect against enemy capital ships but starfighters were not considered a threat in the design of the first Death Star. The first Death Star therefore had a vulnerability in an exposed thermal exhaust port which Rebel starfighters with proton torpedoes exploited in order to destroy it. This vulnerability was fixed in the design of the second -- the large thermal exhaust port was replaced with numerous smaller ports. Once fully constructed the second Death Star would theoretically be invulnerable to both capital ships (due to the built-in shield generators) and starfighters (which would not be able to launch proton torpedoes into a large thermal exhaust port as they did with the first Death Star).
However, the second Death Star was still vulnerable while its internal structure was exposed during construction:
Starfighters would be able to fly into the incomplete superstructure of the second Death Star unless protected by a shield generator (which the Rebels did at the Battle of Endor). The built-in shield generators of the Death Star were evidently not complete, so the Empire built a shield generator on the forest moon of Endor to protect the Death Star until construction was complete.
The shield generator on the moon of Endor was there to provide protection during the construction phase. Since the Death Star II was not complete, it wasn't yet able to generate its own shields like the original Death Star.
Once construction had completed, the Death Star II could move away from the moon under its own shield protection.
Nobody has mentioned this yet, but the shield generator being on Endor was also a trap.
The Rebels were unwittingly falling into a trap devised by the Emperor himself. In an attempt to effectively eliminate the Rebellion, Palpatine planned on drawing the Alliance to Endor using simple disinformation: he hid the fact that the station's primary defense systems were already operational. With a large naval force hidden on the far side of the moon and an elite legion of Imperial troops standing by on the moon's surface near the shield generator, he was ready to crush the Rebels once and for all.
The shields of the two Death Stars were significantly different.
The original Death Star was rather poorly shielded; traditional attacks from capital ships could be easily repulsed, but the shields did not prevent close-range (near point-blank) attacks. The shields also did nothing to prevent enemy fighters from entering the Death Star's "airspace;" in episode IV the Alliance fleet is able to pass directly through the shields with nothing more than minor turbulence.
As the second Death Star was constructed, fighter attacks were acknowledged to be a significant threat. Priority was placed on creating a shield that was strong enough to physically repulse starfighters. Generating such a shield required immense energy; additionally, the shield needed to be fully functional from the outset of construction. For this reason, the shield generator was placed on Endor while the building began in space.
This shield is the primary reason that the attack on the second Death Star could not begin until the generator on Endor had been destroyed. Such "impenetrable" shielding gave the Empire a false sense of security, and is the main reason that they never considered the second Death Star to be at risk.