From the Catechism:
1713 Man is obliged to follow the moral law, which urges him “to do what is good and avoid what is evil” (cf. *GS *16). This law makes itself heard in his conscience.
1714 Man, having been wounded in his nature by original sin, is subject to error and inclined to evil in exercising his freedom.
324 The fact that God permits physical and even moral evil is a mystery that God illuminates by his Son Jesus Christ who died and rose to vanquish evil. Faith gives us the certainty that God would not permit an evil if he did not cause a good to come from that very evil, by ways that we shall fully know only in eternal life.
**312 **In time we can discover that God in his almighty providence can bring a good from the consequences of an evil, even a moral evil, caused by his creatures: “It was not you”, said Joseph to his brothers, “who sent me here, but God. . . You meant evil against me; but God meant it for good, to bring it about that many people should be kept alive.” From the greatest moral evil ever committed - the rejection and murder of God’s only Son, caused by the sins of all men - God, by his grace that “abounded all the more”, brought the greatest of goods: the glorification of Christ and our redemption. But for all that, evil never becomes a good.