Proverbs 17:3 (ESV)  The crucible is for silver, and the furnace is for gold, and the Lord tests hearts.

The LORD here is compared to that which is used to burn off impurities out of metal in order to make them more pure. The analogy is obvious. The troubles of life are the works of God for the purpose of driving us to greater conformity to Christ. God is testing our hearts. A faith that cannot stand trial is no faith at all. The Gospel is not a call to come and follow in an environment of safety and easy sailing. It is a call to die, to suffer, to warfare and pain and loss.  For the child of God there is comfort even in trouble – God is using it for their good.