The Holy Spirit makes us discern between trials, which are necessary for the growth of the inner man, and temptation, which leads to sin and death. We must also discern between being tempted and consenting to temptation. Finally, discernment unmasks the lie of temptation, whose object appears to be good, a "delight to the eyes" and desirable, when in reality its fruit is death.
God does not want to impose the good, but wants free beings. . . . There is a certain usefulness to temptation. No one but God knows what our soul has received from him, not even we ourselves. But temptation reveals it in order to teach us to know ourselves, and in this way we discover our evil inclinations and are obliged to give thanks for the goods that temptation has revealed to us."
-Origen quoted in CCC 2847