The demons attack the person who has attained the summits of prayer in order to prevent his conceptual images of sensible things from being free from passion; they attack the gnostic so that he will dally with impassioned thoughts; and they attack the person who has not advanced beyond the practice of the virtues so as to persuade him to sin through his actions. They contend with all men by every possible means in order to separate them from God. […]
There are said to be five reasons why God allows us to be assailed by demons. The first is so that, by attacking and counterattacking, we should learn to discriminate between virtue and vice. The second is so that, having acquired virtue through conflict and toil, we should keep it secure and immutable. The third is so that, when making progress in virtue, we should not become haughty but learn humility. The fourth is so that, having gained some experience of evil, we should ‘hate it with perfect hatred’ (cf. Ps. 139:22). The fifth and most important is so that, having achieved dispassion, we should forget neither our own weakness nor the power of Him who has helped us.
By St. Maximos the Confessor,
Four Hundred Texts on Love 2.90, 2.67