In the earliest days of the kingdom of Egypt, about 4000-3500 BC, Egypt was still divided into the two countries of Upper Egypt and Lower Egypt. Even so long ago, most people already lived in houses built out of mud-brick, as they would throughout Egyptian history, and as many people in Egypt still do today.
This was so long ago that Egyptian architects couldn’t really build anything much more complicated than a house yet. The only other thing they built (that we know about) was tombs called mastabas. A mastaba was a small, low stone building to put a dead person in. So it was like a house for the dead.
Egypt’s dry climate naturally preserved dead people’s bodies as mummies, and naturally Egyptians thought that if people’s bodies were going to stick around after death, they’d need houses to live in. That’s what a mastaba is.
Pyramid, by David Macaulay (1982). His architectural drawings are great, and his explanations are simple and clear. Easy reading.
Eyewitness: Pyramid, by James Putnam (2000). Easy reading. Good photographs.
The Art and Architecture of Ancient Egypt (Yale University Press Pelican History of Art), by William Stevenson Smith and William Kelly Simpson (revised edition 1999). Standard college textbook.