It was probably built to protect the pharaoh's tomb
or
if you want the middle pyrmid
The middle pyramid at Giza was built for Khufu’s son Khafre (2558-2532 B.C). A unique feature built inside Khafre’s pyramid complex was the Great Sphinx, a guardian statue carved in limestone with the head of a man and the body of a lion. It was the largest statue in the ancient world, measuring 240 feet long and 66 feet high. In the 18th dynasty (c. 1500 B.C.) the Great Sphinx would come to be worshiped itself, as the image of a local form of the god Horus. The southernmost pyramid at Giza was built for Khafre’s son Menkaure (2532-2503 B.C.). It is the shortest of the three pyramids (218 feet) and is a precursor of the smaller pyramids that would be constructed during the fifth and sixth dynasties.