Desertification pushed people to regroup along the Nile and create a country. However, in Khufu's time there was still a large strip of savannah along the river valley. We can also see scenes of hunting gazelles or lions in Egyptian tombs. So the pyramids were not built in the desert but in a dry savannah.