The main reason the kings of Egypt built the pyramids was due to what they believed about the afterlife. Ancient Egyptian society believed that when the pharaohs died, they became the god Osiris. But, for the king to survive in the afterlife, it was vital that his ka (which was similar to a soul or spirit) survived.