A question I commonly hear is, "Why is God allowing me to suffer?" At the root of this question is the belief that the suffering is undeserved. It is a karma type of philosophy (i.e. if you are good, good things happen and if you are bad, bad things happen). Fortunately, God does not operate on the principals of Karma. He operates on the principals of His Will.
Joseph is prime example. Joseph, as far as we know, was a good kid. He had a couple of dreams that he shared with his brothers which resulted in him being sold into slavery and subsequently languishing in prison due to a false accusation of rape. Neither of those life events have I gotten the pleasure of experiencing, nor do I hope I ever do. Make no mistake, his suffering was real and significant.
Eventually, Joseph found himself in a prominent position of power and was able to save his entire family, and an entire nation, from a very devastating drought. When speaking to his brothers who had sold him into slavery, he tells them not to be angry with themselves because is was God who had orchestrated it. If that is true, then it was God who made him a slave and it was God who caused him to be falsely accused of rape and it was God who caused him to languish in a prison cell and it was God who "allowed him to suffer."
Why? "To preserve life." Because of his suffering he was able to save his family and save the nation of Israel. The suffering of Joseph may not have been obvious to him in the midst of his pain, but in hindsight he saw the hand of God.
Therefore, "Why is God allowing you to suffer?" I don't know. The question is almost always unanswerable in the moment, but I do know that the same God that was with Joseph can also be with you. So trust in Him. I am guessing that if you do, you will look back someday and reflect upon the dark valleys of your life and you will see God's hand guiding you. In that moment you might find yourself saying thank you instead of asking why.