Recently I re-watched Oceans Eleven, the story of a casino robbery. The reason why the robbery was successful was because the thieves knew the casino owner so well. They spent time watching his every move. They watched how he reacted under pressure. They knew what was important to him. By the time the robbery was in process the thieves were able to manoeuvre the owner into being where they wanted him to be, seeing what they wanted him to see. The owner thought he had a fool proof security system but it was thwarted by the thieves' superior knowledge.
Likewise God knows Satan. He knows his every move; how he reacts under pressure; what's important to him; God knows everything about him. God knew that Satan would orchestrate the death of his Son. So much so that God would prophesy about it in Isaiah 53, decades before it happened. It wasn't that God plotted to kill his own Son but rather he gave Satan an opportunity.
In a like manner it is not the sun that causes darkness but rather it is when the sun withdraws that there is darkness. Sometimes God withdraws his protection and Satan has an opportunity. We see this in the book of Job when God withdraws his protection from Job.
We can live securely in the knowledge that God is never the initiator of evil. He sometimes withdraws his protection and allows evil but only if he can bring good from it. God is never surprised by Satanís tactics, or by evil people.
It is a great comfort to know that God's plans can not be thwarted by Satan. This is a truth Job learned through his trials, "I know that you can do all things; no purpose of yours can be thwarted" (Job 42:2) and something we can rely on.
We can rest in this knowledge and know our lives are safe in His hands.