The ancient Egyptians believed in life after death and so, more than anything else, they were concerned about the afterlife.
So that they would not be damned by the gods when they died, ancient Egyptians believed they had to worship the gods and live by a code that the gods set.
What code the people followed depended on how the priests and the pharaoh interpreted what the gods wanted. From time to time, such as during the reign of Akhenaten, the pharaoh decided to have a change of gods, and this caused much distress.