While there’s always more to say on the subject, we do have a section of the FAQ on building the pyramids, including these particularly relevant answers:
Exactly how were Ancient Egyptian pyramids built? by u/Tiako
Why was there such a long period without the construction of pyramids in ancient Egypt? Khendjers reign was around 1760BC and and the next pyramid wasn't erected until 721BC by Piye? by u/Bentresh which gets into some reasons they were built to begin with
To which I would add What was the purpose of the pyramids? by u/alfihar