During times of illness, we may fail to see the purpose for this type of suffering. Falling into despair, we may believe we’re being punished or think that God has abandoned us. However, God is fully present and illness is part of His plan for our salvation and the salvation of humanity if we come to understand what we are to do.
The Catechism of the Catholic Church paragraphs 1499-1505 explains how illness, when embraced as redemptive suffering, can be used to save souls, as well as our own, and brings to greater union with Jesus Christ.
The Catechism of the Catholic Church Online