Humans organization has been changing, since their beginnings.
Some of these changes were most evident during the Bronze and Iron ages (3500-1000 B.C.E), where civilizations such as the Nile Valley and Mesopotamia flourished. Each of these civilizations believed in something ranging from Marduk or Ra. Writing like cuneiform and hieroglyphics were a standard sight throughout these regions. Though these regions shared many things, had their own distinct styles of governments. Both Mesopotamia and Egypt had religion and writing.
Despite these similarities, they had different types of government. The two civilization shared religion as a common ground between both of these civilizations. Gods were a concurrent theme throughout each of the polytheistic civilizations. Aspects of nature, e.g. wind, water, and solar, etc, are what these gods represent.
Each civilization dedicated lavish structures to their gods. Ziggurats were a common sight in the fertile crescent. In both civilizations, religion is used as a justification for ruling. “When Marduk sent me to rule the people and to bring help to the country, I established law and justice in the land and promoted the welfare of the people”. The people respected these gods as above human. Hammurabi was able to assert his rule through religion.
In Egypt, the pharaoh was able to command the labor force to construct a pyramid for the afterlife. This building process requires 10s of 10,000 of people. The only way that this massive superstructure would come to fruition is if the monarch had a connection a with the divinity.
What the pharaoh the ability to rule, was the affiliation with the divine. The authority of the king and pharaoh stem from one place: the gods, i.e., religion.