My current UPG is that, at a level of manifestation before the physical, and above and beyond (behind?) many other spirits, there arose a need for chaos to generate things which had never existed before, to prevent stagnation and collapse.
This collapse would otherwise have arisen because without the chaos, the powerful randomness, the manifest forms and outcomes, which are determined by probability, would have been already-known, seen (and therefore observed, and collapsed) - this chaos may have taken masks or forms, one of which is known as Set.
Set defeats Apep in the lore - Apep being, in that example, the collapse into decay.
That roaring dark storm gave rise to a lucid point of complete isolate awareness, which some call Lucifer.
Another version of this may be Keket, the female black snake of chaos, who gave rise to Kek, her husband, who manifests as the lucid point of consciousness that emerges from chaos (as a frog emerges from the waters).
All of these, Lucifer, Set, Kek and Keket, are “satan” in one sense, adversaries of the “light,” clockwork-like, probablistic force.
A primordial sea, or milk, or animal (wild beasts are chaotic to us) that’s slaughtered by one man or a group with wisdom are found throughout the world’s creation stories.
it also represents the coming-into-awareness of human life, from the maletrom of helplessness, emotion, and frustrations of babyhood, into dawning self-awareness, realistion that the world is Other, and can be manuipulated by us.
That’s my take on it, but I probably left things out.
Further sources on Kek (since he gets a lot of attentoin round here!):
Kek and Keket in some aspects also represent night and day, and were called “raiser up of the light” and the “raiser up of the night”, respectively.
Source
As a god of the night, Kek was also related to the day - he was called the “bringer-in of the light”. This seems to mean that he was responsible for the time of night that came just before sunrise. The god of the hours before day dawned over the land of Egypt. This was the twilight which gave birth to the sun.
Source