Without temptation, there would be no opportunity for us to grow in virtue every time we successfully resist the allure of sin and remain faithful to God’s will. It is true that God could restrain the demons so that they would be unable to interfere in the history of humanity, but He allows their diabolical work so that it can be an occasion of virtue for us. In other words, we could say that God permits a certain amount of darkness in this world (i.e., temptation and sin) so that a purer and brighter light (i.e., virtue and salvation) can be gained. So God allows temptation because He knows that much good can come from it if we resist.