God's glory is shown most when we've been in long seasons of testing. So, don't think that your struggle is a punishment for something you did or are doing wrong. Instead, consider it a sign that God wants to give you a victory greater than your human mind can imagine and greater than what you can do out of your own ability.
Remember, we can't have a testimony without a test and if you're like me I've wanted every aspect of my life to be a testimony of God's love and power. Sure enough, every test I've experienced has provided an opportunity for God to show himself as the loving, omnipotent father he is. Going through the test is never easy and there are many times you will question the process, but it leads to you surrendering yourself and the situation to God, so that he is finally able to move without you ever thinking it was a result of something you did.
“But He said to me, My grace (My favor and loving-kindness and mercy) is enough for you [sufficient against any danger and enables you to bear the trouble manfully]; for My strength and power are made perfect (fulfilled and completed) and show themselves most effective in [your] weakness. Therefore, I will all the more gladly glory in my weaknesses and infirmities, that the strength and power of Christ (the Messiah) may rest (yes, may pitch a tent over and dwell) upon me!”
2 Corinthians 12:9 AMPC