Isfet (Egyptian mythology)
Isfet or Asfet (meaning "injustice", "chaos",  or "violence"; as a verb, “to do evil”) is an ancient Egyptian term from Egyptian mythology used in philosophy, which was built on a religious, social and politically affected dualism. Isfet was the counter to Maat, which was order. Isfet did not have a physical form. Rather, it was believed that Isfet was personified in the form of Apep. Isfet was important in Egyptian culture as Isfet showed that there is balance in the world. Principles and ideology 
Isfet was thought to be the counterpart of the term Ma'at (meaning "order" or "harmony"). According to ancient Egyptian beliefs, Isfet and Ma'at built a complementary and also paradoxical dualism: one could not exist without its counterpart. Isfet and Ma'at balanced each other. Ma'at was to overcome isfet, 'that which is difficult', 'evil', 'disharmonious', and 'troublesome'. Isfet was to be overcome by good, which would replace disunity with unity and disorder with order. An Egyptian king (pharaoh) was appointed to "achieve" Ma'at, which means that he had to keep and protect justice and harmony by destroying Isfet. A responsible kingship meant that Egypt would remain in prosperity and at peace in Ma'at. However, if Isfet were to rise, humanity would decay and return to a primordial state. Decay was unacceptable as a natural course of events, which meant that the world was separated from the cosmos and away from order. The universe was cyclical, meaning it had repeated sequences: the daily sunset and its rising, annual seasons and flooding of the Nile. On the other hand, when Ma'at was absent, and Isfet unleashed, then the Nile-flood failed and the country fell into famine. Therefore, ancient Egyptians believed through their rituals of the cosmic order it would bring forth prosperity to the gods and goddesses who controlled the cosmos. The principles of the contrariness between Isfet and Ma'at are exemplified in a popular tale from the Middle Kingdom, called The Moaning of the Bedouin:

In the eyes of the Egyptians, the world was always ambiguous; the actions and judgments of a king were thought to simplify these principles in order to keep Ma'at by separating Order from Chaos or Good from Evil. Coffin Text 335a asserts the necessity of the dead being cleansed of isfet in order to be reborn in the Duat. Isfet is thought to be the product of an individual's free will rather than a primordial state of chaos. In mythology, this is represented by Apep being born from Ra's umbilical cord relatively late. Duality 
In Egyptian culture duality was important. In order for duality to exist there had to be two opposing forces. The counter to Isfet was Ma'at. Ma'at was said to bring order whereas Isfet brought chaos. This created the concept of duality. Creating two opposing forces that existed simultaneously. The Egyptians believed that the world could not be balanced without this duality; which is why they believed in both Isfet and Ma'at. Role of the king
When the king made public appearances he was surrounded by images of foreigners which emphasized his role as protector of Ma'at and the enemy of Isfet which were foreign enemies of ancient Egypt. As such, the king is mainly shown 'smiting' foreigners to maintain Ma'at. The king also maintained the temple-Cult to prevent Isfet from spreading, by ensuring the rituals were performed at defined intervals, which were necessary in preserving the balance of Ma'at against the threatening forces of Isfet. References 

Ancient Egyptian religion
Injustice
Violence
Ancient Egyptian philosophy