Simply put, the Endor system was simultaneously incredibly remote (dramatically lowering the chances of anyone stumbling onto the project by accident) and highly accessible if you knew the secret navigational codes that were required to access the "Sanctuary Pipeline", a lengthy hyperspace route that led directly from Sullust to Endor.
Red lines appeared on the spiral arms—the great trade routes that connected the galaxy’s star systems. Ackbar gestured, and a red dot sprang into existence in a location Leia recognized: Sullust, the homeworld of Nien Nunb. Then another dot appeared, on the edge of the galaxy. A dotted blue line stretched between them.
“The Empire has used S-thread boosters to create and maintain a secret
hyperspace route running from Sullust all the way to the galactic
edge,” Ackbar said. “It’s called the Sanctuary Pipeline and is one of
the Empire’s most important military secrets. Fortunately, our agents
discovered the navigational data that will allow us to use it, too.”
Star Wars: Moving Target
As to why Endor was chosen (over, say, another more accessible but still unexplored planet), that was down to the Emperor himself.
The shield generator could have been built in any of thousands of desolate, lifeless planetary systems. But the Emperor himself picked this spot from several suggested by Imperial engineers.
The engineers liked the idea of burning up the moon’s resources to fuel the shield.
And the Emperor liked the idea of crushing something beautiful.
Return of the Jedi: Beware the Power of the Dark Side!