It's a question we all ask God when we experience pain and suffering. The common understanding of Christianity is that because we are in Christ we won't have to worry about bad things that happen to us.
Sadly, it's a misconception that lead many people into disappointment. God never promises us problem-free lives when we surrender to Him. 1 Peter 4:12 says it this way- "Beloved, do not be surprised at the fiery trial when it comes upon you to test you, as though something strange were happening to you." Trials will still be a part of our life even when we live lives for Jesus.
But all this of course is for a reason. Rest assured God always allows things to happen for a purpose and usually it's always for our overall good (Romans 8:28) because He loves us. Why does God allow pain and suffering? Here are a few good reasons why.
To allow us to grow
Romans 5:3-4 has this to say to all of us on suffering: "Not only that, but we rejoice in our sufferings, knowing that suffering produces endurance, and endurance produces character, and character produces hope." Trials may be hard, but we have to admit that if all things were easy then we wouldn't grow much.
God allows for suffering to happen so that we may experience growth. God's Word also promises that there is never a challenge that we cannot handle (1 Corinthians 10:13).
To cause us to trust in Him
Psalm 18:6 tells us, "In my distress I called upon the LORD; to my God I cried for help. From his temple he heard my voice, and my cry to him reached his ears." The Psalmist has a very important principle to teach us here that may not be obvious right away- if there's one thing trials cause a Christian to do, it's to call upon and rely on God.
If everything were too easy, we wouldn't really be intentional in our approaching God. But God wants us to draw close and to seek Him because He wants a relationship with us. Many times (not all the time but many times) He uses trial to do so.
To magnify the glory of heaven
The world is wonderful as we know it, but as we know it's not perfect. That's because sin has stained our reality and distorted all that God created "good." (Genesis 1:31) So why doesn't God just fix everything?
There is a very strong theological foundation to this that could go for pages and pages, but one of the many reasons is because the imperfection of this world will only highlight the future glory of God's fulfilled promised of heaven on earth when that time comes. When will that happen? No one knows for sure, but it's coming. And when that day comes we will only look back to our momentary afflictions and say that it was all worth it.