Once separated, Upper and Lower Egypt were joined and united by a pharaoh named Menes. Menes was not only famous for uniting Upper and Lower Egypt, but he also started the First of all 31 Dynasties.
The Great Pyramids were mostly built from the 1st-6th dynasties, with the 6th dynasty marking the start of the decline of the pharaoh's power and prestige.