Not only so, but we also glory in our sufferings, because we know that suffering produces perseverance; perseverance, character; and character, hope. – Romans 5:3-4 NIV
When I was a kid, I would periodically watch my dad cast lead fishing weights. He had a little frying pan on the stove and would put chunks of lead into it. The lead would eventually melt, and when it did so there was usually a layer of impurities that would float to the top. Dad would scrape off and discard these impurities before pouring the molten lead into his molds. And I understand the same thing is done with gold or silver in their refining process. The intense heat in the refining process will separate the impurities out of the metals, leaving them pure and more valuable.
I believe that is what Paul (and James in James 1:2-4) has in mind here when he calls on us to glory in our suffering. The trials in life that we go through can function much like the refiners fire (1 Peter 1:6-7), separating the impurities out of our lives and making us more useful to the refiner. We should rejoice, or glory, in our sufferings, not because the suffering is pleasant, but because of what God can do with it (Rom. 8:28).
In Hebrews 12:7 we are told to treat hardship as discipline. Then in verse 11 we find ” No discipline [hardship] seems pleasant at the time, but painful. Later on, however, it produces a harvest of righteousness and peace for those who have been trained by it.” In the midst of your trials, thank God for how he might be using them to teach you and to develop your character.