Let us introduce the concept of the different wills of God. There are “will”s of God. There is a Moral Will and there is a Sovereign will.
The Moral Will: This is the will that is indicated when the Bible asks us to not sin. God would like us not to sin in His Moral will. But obviously we sin. If God didn’t want anyone to sin then no one would sin (otherwise God is not Omnipotent). But mankind sins. So we have a choice. Either God is incapable of preventing us from sinning (silly idea) or God allows us to sin. So we came up with the second type of God’s will.
The Sovereign Will: This is the will that actually happens. E.g. It was God’s Sovereign Will that Jesus was to die on the cross.
Do you see the difference: It was God’s Moral Will that everyone obey God and not kill Jesus. But it was God’s Sovereign Will that Jesus be killed.
Anything that happens is God’s Sovereign Will. We constantly pray that God would choose to make his Moral Will and His Sovereign Will coincide.
Another example. It is God’s Moral Will that you obey Him and be blessed. But it was God’s Sovereign will that you rebelled, fought against the wisdom of God, did stupid things, suffered from it, then learned from it and came back into obedience.
Note that this is just mankind’s attempt to comprehend a portion of the nature of an infinite God. We can’t ever fully comprehend Him, but this distinction allows us to differentiate between the things that happen that are allowed by God and the things that God indicates he would have us do (e.g. Obey him).