Actually, I don't know what you think it's for. Some people think God is punishing us. Some people think it's to teach us a lesson. Some people think we deserve whatever suffering comes our way. Some of this might be true -- the part where God is teaching us something, but after a conversation my Sunday School class had last Sunday I think there is a reason for suffering that supercedes all other reasons.
The principle goes back to a story in the gospel of John chapter 9 where the disciples asked Jesus about a blind man. They asked, "Rabbi, who sinned, this man or his parents, that he should be born blind?"
Jesus answered, "It was neither that this man sinned, nor his parents; but it was in order that the works of God might be displayed in him."
In class we talked about how people see God when His children suffer well. I think a big reason for our suffering is for the benefit of others. They need to see God is bigger than the pain of this world. They need to see God carry us through the suffering. If we suffer well, people's eyes will be drawn to God for only He can get the glory for this kind of suffering. Maybe when bad things happen to us, it is God believing in us, believing that we will trust Him to get us through. Maybe someone needs to see that trust lived out.
Hebrews 11:6 says, "he who comes to God must beleive that He is, and that He is a rewarder of those who seek Him."
God rewards our trust in Him. He always comes through. He doesn't want to see us suffer, but suffering is part of this world. He can use it to bring us and others closer to Himself.
In class we also talked about what happens when someone gets a huge windfall or wins the lottery or gets a huge inheritance. Usually God is not glorified in that. People say that person was lucky. Or people say, "I wish I had a rich relative."
God's ways aren't our ways. If showering people with all sorts of worldly goods would increase their faith and bring them into relationship with Jesus, God would do that. But He knows us better than we know ourselves.
If you're suffering look up. Realize God is using it in wonderful ways. And realize it is also finite. There is an end to it. Just keep holding on. God's got you.