Man created god to give power to his ego and created Satan as a way to excuse his bad behavior. It's not some deep mystery, it's the predictable result of an immature mind.
When our ancestors first learned to question the world around them, gods were created. When they couldn't craft a credible story line with just the hero of the story, they gave it a villian.
Religion is fascinating, but it is still fiction.