For example, God says not to have sex before or outside of the marriage relationship . But if people insist on doing so, and suffer consequences such as unwanted pregnancies, diseases, abortions, emotional upset and torment, unpleasant memories, etc., from committing adultery, fornication, etc., then whose fault is it? If he denied us freedom to sin, people would complain about not having the freedom to find out if some other way besides God's way would work.
Presumably, a similar issue came up among the angels. Satan attacked the Creator and his character, and got one-third of the angels (Revelation 12:9) to side with him. These angels, like many of us humans, didn't trust God or have faith in his revealed will as a loving and unselfish Being. He is presently allowing these spirit beings (the demons) to learn, along with humanity, that disobeying his laws is not a successful or happy way to live.
God may also be allowing Satan to operate in order to help us develop holy righteous character more quickly, since Christians have to learn to resist against Satan's influence. Here the analogy would be with weight-training and the concept of resistance, only there's a spiritual principle being applied here: We develop the habits of obeying by our own free choice more solidly and permanently if we have to resist more in order to develop them.
Not only could the devil been put to death when he sinned, but also Adam and Eve. The Eternal, however, decided IN ADVANCE that if they (the humans) did sin, He would pay the price personally. Always remember, in Christianity, Jesus chose to give up his divinity and to suffer like humans from the consequences of sin and living in a world cut off from the Creator. He didn't live an easy, sheltered life in the lap of luxury. Instead, He chose to die a horribly pain and humiliating death for people (in most cases) who didn't know what He did or who actively consented to His death. We should, therefore, have faith in our Father that He knows what He is doing when He allows sin temporarily to exist in the universe as a temporary, unwelcome visitor.
God is in the process of making beings like Himself that have 100% free will (like He does) yet will also obey His holy righteous law of love 100% of the time (like He does also - compare with Matthew 5:48). This would be the main reason he allows evil to exist by deduction from the Biblical evidence.
We are not in a position to judge God and His actions, as Job did. Let's be humble and patiently await the day He'll abolish all sin and take care of the devil for all eternity.