There have been many leaders throughout history claiming a kinship with the gods of their culture, and the Pharaohs of Egypt held that distinction. While they did build many cities and structures, the pyramids are some of their best preserved works in this area. They were houses that were meant to help them on their journey to the afterlife, and their building was done throughout the reign of each Pharaoh so it would be ready upon their death.
As a home for their earthly body, the Pharaohs insisted their pyramids had to contain treasures and foods that would help them along their journey. Many chambers were built inside them for food, drink, and their servants to reside in death with them. Some of the rooms were hidden because they housed the artwork and treasures amassed by the Pharaoh in life, so they needed to be secured from the depredations of grave robbers.