I strongly recommend this book for a really good look into this complex subject
Amazon.co.uk User Recommendation
In dualistic religions like manachaeism or Catharism an evil deity explains evil in the world.
Monotheistic religions have a problem with this and the Devil kind of hung over in this role in the middle ages until the "it's free will" (in other words blame yourself) doctrine and the "Gods will is unknowable" (in other words shut up and go away) doctrine took over.
You'll actually find very little of the devil in the bible and where you do he's a figure of temptation. Garden of Eden, Jesus being tempted in the dessert - even God being tempted to test Job.
The Dennis Wheatly, prince of Evil satan I guess springs from that perennial favorite of nutters the book of revalation and gets elaborated over the middle ages by the Catholic church.