Would Pharaohs not have preferred their burial chambers to be right outside if large cities, where everyone could see them?
Actually, the major pyramids were located close to the major population centres of the time. The necropolis at Saqqara, which contains the Step Pyramid and many other Old Kingdom funerary complexes, was located next to the then capital of Memphis, and that at Dashur (home to the Bent Pyramid) is only a couple of kilometres further to the south.
Giza is about 12 miles of north of Memphis and it is usually assumed that the site was selected because it forms a substantial plateau with good access to the Nile, along which the stones needed for construction were moved.
Of course, quite famously, Giza is also now literally on the edge of modern Cairo.