Answer:
They were built for religions purposes because people believed in the afterlife then and the pyramids were where they laid the wealthy to stay until the afterlife.