Jesus... was led by the Spirit into the desert for forty days, to be tempted by the devil.
Msgr. Peter Magee, in God's Mercy Revealed: Healing for a Broken World, suggests that it is "unsuspected, unexpected, strange even," for the Holy Spirit to lead Jesus into temptation this way. As Christians, we are both to allow the Holy Spirit to guide us, and to pray, "Lead us not into temptation." So what if the Holy Spirit guides us into temptation?
it must be known that to tempt is nothing other than to test or to prove. To tempt a man is to test or try his virtue.
"To tempt," then, isn't the altogether wicked thing we might usually consider it, although if you're going to tempt someone, you'd better have the right and authority to be testing his virtue.
That's just the sort of right and authority God has, and so sometimes
a person is tried in his readiness to do good, for example, to fast and such like... In this way does God sometimes try one's virtue, not, however, because such virtue is hidden from Him, but in order that all might know it and it would be an example to all.
Tested virtue is an example first to the one whose virtue it is; such tests make virtue stronger and more pure. Msgr. Magee goes as far as to say that "temptation is the opportunity we need to use those gifts [of nature and grace] aright." If we do good when our readiness to do good isn't tested, what good is that? Even sinners do it.
We shouldn't merely endure the trials into which the Holy Spirit leads us, we should welcome the transforming fire (as Msgr. Magee calls it) they put us in. The Greek version* of Judith 8:25 tells us that
we should be grateful to the Lord our God, for putting us to the test, as he did our forefathers.
Now, the second kind of temptation, per St. Thomas, is when
the virtue of man is tried by solicitation to evil. If he truly resists and does not give his consent, then his virtue is great. If, however, he falls before the temptation, he is devoid of virtue. God tempts no man in this way, for it is written: "God is not a tempter of evils, and He tempteth no man."
So if there's a good kind of temptation, which we need to grow in virtue, and a bad kind of temptation, by which God never tempts us, then what's the point of asking God not to lead us into temptation? St. Thomas replies
that God is said to lead a person into evil by permitting him to the extent that, because of his many sins, He withdraws His grace from man, and as a result of this withdrawal man does fall into sin.
In other words, the petition amounts to, "Do not abandon us when we are tempted to sin." It is a way of praying for the promise St. Paul records in 1 Corinthians 10:13:
God is faithful and will not let you be tried beyond your strength; but with the trial he will also provide a way out, so that you may be able to bear it.
By petitioning God to do what He has promised to do, we draw our own hearts, minds, and wills closer to His.
*. I point out that I'm quoting the Greek version because it's considerably different from the Latin version. The Douay Rheims translates St. Jerome's Vulgate, which he claimed to have translated in one night from the Chaldaic, "magis sensum e sensu," aiming at giving sense for sense (i.e., dynamic equivalence!). The Latin version is shorter than the Greek version (which the NAB translates), and doesn't contain the words I quote above.