"It is good for me that I have been afflicted"
(Psalm 119 v 71)
The ungodly world would think that the statement above is crazy. The world sees health and wealth for oneself and one's family as the ideal. It does not see anything good about suffering any kind of affliction at all.
David however realised that God had used afflictions in his life for his spiritual good. He speaks of learning more of God's word, as well as increasingly keeping it through the afflictions he suffered (Psalm 119 v 67, 71).
Job suffered terrible affliction, losing his business, children and health almost at one and the same time. He realises God used all of this for his spiritual good saying "When He hath tried me, I shall come forth as gold." (Job 23 v 10). Just as a furnace is used to refine and purify certain metals, removing any impurities, God uses afflictions to burn up things contrary to His will in the believer in Christ. The furnace gets very hot in purifying metals and sometimes the trials needed to purify the believer can be very hot, very difficult.
All God's children through faith in Christ Jesus should know God their heavenly father is too wise to be mistaken, too good to be unkind. So even in our various trials and afflictions we can rejoice knowing God uses them for a glorious end "The trial of your faith, being much more precious than gold that perisheth, though it be tried with fire, might be found unto praise and honour and glory at the appearing of Jesus Christ" (1 Peter 1 v 7).