Haven't done any reading on this since I studied ancient Egypt for a project at school but I thought ancient cultures built pyramids to get closer to God or gods.
Whether to get worshippers at a religious site closer to gods and heaven or to get the deceased who was buried inside it closer to the afterlife. It seemed natural for ancient peoples to think gods were up in the sky because they certainly weren't down here.