The Egyptian pyramids were built in what archeologists call the Old Kingdom period of Egypt’s history. It is believed that this kingdom rose up sometime after the year 3,000 BC, and that the Giza pyramids were built between 2589 and 2504 - taking the entirety of that time span to built them all. The Great Sphinx of Giza is also thought to have been built during this time. These projects spanned the rules of at least two dynasties, possibly three.
Pyramids were built as elaborate tombs for their pharaohs. There are many halls and a maze of rooms for grave robbers to get lost in. Often times, thousands of slaves would be buried alive in the pyramids with the pharaohs, to serve in in the afterlife.