Don't forget that believers, NOT The Lord, get themselves in certain situations and problems, because of their disobedience unto His word, lack of holiness, stubbornness, worldliness, insensitivity to the Holy Spirit etc. A lot of pain and agony is flooding the lives of believers due to sin, which they have allowed in their hearts and lives. If you abide in Me, and My words abide in you, you will ask what you desire, and it shall be done for you. Born-again believers have to learn to obey God and walk in His ways. If we are not too willing, the Lord allows a few pains here and there.
Sin is dirty and satan is merciless.
Often the pain is a consequence of sin. Nevertheless, the Lord uses any opportunity to draw the attention of His children and bringing them closer to Himself. Sometimes, because of stubbornness, believers may have to hit their head hard before they totally surrender and learn to deny the flesh, allowing The Lord to be Master in their lives. If you are not willing to learn, painful events will be repeated, years will be lost, struggle will continue, frustration will be all around. You have to shake it all off, and allow the Lord to take over.