I have wondered if Satan isn't a necessary part of creation,
Only necessary if God deemed it necessary.
whose role is to teach us not to yield to temptation.
Hmmm...
That's not working too well then, is it?
However, it did turn out to be a role for him.
I think the Bible explains enough about how and why, and we can even understand it i.m.o.
Here was this most beautiful cherub God has made, and suddenly he was put lower n the hierarchy when God created man and gave him dominion over the earth.
I can understand that he instantly hated man and basically killed him (made him mortal) and gained the rule over the earth.
He also found other gods to rebel against God.
Why this is possible and a risk God apparently took, is because God created beings with a free (or personal) will.
When God wants to be loved by his created beings, He has to give them free will, otherwise they would be robots, programmed to love God, which would basically mean God loving Himself by means of robots...