Why does God permit temptation?


“One can distinguish five reasons why God allows the devils to attack us:
first, so that from attack and counter-attack we may become practised in discerning good from evil;
second, so that our virtue may be maintained in the heat of the struggle and so be confirmed in an impregnable position;
third, so that as we advance in virtue we may avoid presumption and learn humility;
fourth, to inspire in us an unreserved hatred for evil through the experience we thus have of it;
fifth, and above all, that we may attain inner freedom and remain convinced both of our own weakness and of the strength of him who has come to our aid.” – St. Maximus the Confessor
In a word, God permits temptation for our greater good. The more we are tempted, the more right we have to trust in Him, without Whom it would be impossible to overcome even the slightest temptation. God rewards our efforts generously in Heaven.
***

The Lord said to St. Bridget, “In order that man may understand his own weakness, and the strength he receives from Me, it is necessary that he should sometimes be allowed to be attacked by evil thoughts; and if he consents not to them, they become the purification of his mind, and the safeguard of his virtues. And although they are hard to be borne, they heal the soul, and conduct it to eternal life, which cannot be gained without sufferings. The soul should, therefore, labour diligently, lest it consent to them, or take any pleasure in them.” 


https://littlestsouls.wordpress.com/2014/01/26/encouragement-for-those-tried-by-unwanted-thoughts/