From the encyclical Salvific Doloris:
Down through the centuries and generations it has been seen that in suffering there is concealed a particular power that draws a person interiorly close to Christ, a special grace. To this grace many saints, such as Saint Francis of Assisi, Saint Ignatius of Loyola and others, owe their profound conversion. A result of such a conversion is not only that the individual discovers the salvific meaning of suffering but above all that he becomes a completely new person. He discovers a new dimension, as it were, of his entire life and vocation. This discovery is a particular confirmation of the spiritual greatness which in man surpasses the body in a way that is completely beyond compare. When this body is gravely ill, totally incapacitated, and the person is almost incapable of living and acting, all the more do interior maturity and spiritual greatness become evident, constituting a touching lesson to those who are healthy and normal.
This interior maturity and spiritual greatness in suffering are certainly the result of a particular conversion and cooperation with the grace of the Crucified Redeemer. It is he himself who acts at the heart of human sufferings through his Spirit of truth, through the consoling Spirit. It is he who transforms, in a certain sense, the very substance of the spiritual life, indicating for the person who suffers a place close to himself. It is he—as the interior Master and Guide—who reveals to the suffering brother and sister this wonderful interchange, situated at the very heart of the mystery of the Redemption. Suffering is, in itself, an experience of evil. But Christ has made suffering the firmest basis of the definitive good, namely the good of eternal salvation. By his suffering on the Cross, Christ reached the very roots of evil, of sin and death. He conquered the author of evil, Satan, and his permanent rebellion against the Creator. To the suffering brother or sister Christ discloses and gradually reveals the horizons of the Kingdom of God: the horizons of a world converted to the Creator, of a world free from sin, a world being built on the saving power of love. And slowly but effectively, Christ leads into this world, into this Kingdom of the Father, suffering man, in a certain sense through the very heart of his suffering. For suffering cannot be transformed and changed by a grace from outside, but from within. And Christ through his own salvific suffering is very much present in every human suffering, and can act from within that suffering by the powers of his Spirit of truth, his consoling Spirit.
This is not all: the Divine Redeemer wishes to penetrate the soul of every sufferer through the heart of his holy Mother, the first and the most exalted of all the redeemed. As though by a continuation of that motherhood which by the power of the Holy Spirit had given him life, the dying Christ conferred upon the ever Virgin Mary a new kind of motherhood—spiritual and universal—towards all human beings, so that every individual, during the pilgrimage of faith, might remain, together with her, closely united to him unto the Cross, and so that every form of suffering, given fresh life by the power of this Cross, should become no longer the weakness of man but the power of God.