Sometimes God, because He loves us, will bring us into hard situations. The writer of the book of Hebrews writes about this.
And have you forgotten the exhortation that addresses you as sons? “My son, do not regard lightly the discipline of the Lord, nor be weary when reproved by him. For the Lord disciplines the one he loves, and chastises every son whom he receives.” Hebrews 12:5-6
He writes this to Christians who were having a very bad time of it. In writing this he is trying to help the saints understand what is going on with them. He is trying to answer their question, 'What is going on? Why is all this hardship happening?'
First, he explains that the hardships are not to be viewed as something strange. They are a part of what it means to be God's sons. It's a part of what it means to be in God's family.
Second, he uses words that highlight that this discipline is painful. The word translated 'chastises' is used by John when he describes Jesus' torture. There, in John 19, it is usually translated 'flogged' or 'scourged'. That's what God's discipline can feel like. The author of Hebrews is not apologetic about this. It's just a fact. Sometimes the love that God has for us is expressed in discipline that really hurts.
It's important to remember that this is not punishment but rather discipline. We will never be punished for our sins. Jesus has already taken care of that. But we need to learn how to pursue holiness. There are some really bad habits that we need to turn from. Sometimes God will employ painful discipline so that this turning will happen.
The author closes off this section of his letter with a promise.
For the moment all discipline seems painful rather than pleasant, but later it yields the peaceful fruit of righteousness to those who have been trained by it.
It's this promise that we need to cling to when we find ourselves facing God's discipline.