Of the Creation of Man, and of the Arrangement of the World, and of the Chief Good
But when a separation shall have been made between the body and the soul, then evil will be disunited from good; and as the body perishes and the soul remains, so evil will perish and good be permanent. Then man, having received the garment of immortality, will be wise and free from evil, as God is. He, therefore, who wishes that we should be conversant with good only, especially desires this, that we should live without the body, in which evil is. But if evil is taken away, either wisdom, as I have said, or the body, will be taken from man; wisdom, that he may be ignorant of evil; the body, that he may not be sensible of it.
But now, since man is furnished with wisdom to know, and a body to perceive, God willed that both should exist alike in this life, that virtue and wisdom may be in agreement. Therefore He placed man in the midst, between both, that he might have liberty to follow either good or evil. But He mingled with evil some things which appear good, that is, various and delightful enjoyments, that by the enticements of these He might lead men to the concealed evil. And He likewise mingled with good some things which appear evil— that is, hardships, and miseries, and labours— by the harshness and unpleasantness of which the soul, being offended, might shrink back from the concealed good.
But here the office of wisdom is needed, that we may see more with the mind than with the body, which very few are able to do; because while virtue is difficult and rarely to be found, pleasure is common and public. Thus it necessarily happens that the wise man is accounted as a fool, who, while he seeks good things which are not seen, permits those which are seen to slip from his hands; and while he avoids evils which are not seen, runs into evils which are before the eyes; which happens to us when we refuse neither torture nor death in behalf of the faith, since we are driven to the greatest wickedness, so as to betray the faith and deny the true God, and to sacrifice to dead and death-bearing gods.
This is the cause why God made man mortal, and made him subject to evils, although he had framed the world for his sake, namely, that he might be capable of virtue, and that his virtue might reward him with immortality. Now virtue, as we have shown, is the worship of the true God.
Source: The Divine Institutes (New Advent)