God deals with you as with sons; for what son is there whom his father does not discipline? But if you are without discipline, of which all have become partakers, then you are illegitimate children and not sons… All discipline for the moment seems not to be joyful, but sorrowful; yet to those who have been trained by it, afterwards it yields the peaceful fruit of righteousness.
A good loving parent will discipline his or her children to bring them to a point of repentance and submission to that parent. This is often very painful and hard for the parent, who doesn’t like to hurt their children. But they still do so, because they know that it is the loving thing to do for that child. God is the same!
When one of God’s children is living in sin, God will allow painful times to come into their lives to cause them to turn back to Him.
James 4:6 tells us that “God is opposed to the proud, but gives grace to the humble”. He will not restore your fellowship with Him until you come to Him in brokenness and repentance. But that does not mean God just sits and waits for brokenness in you. He will actively work in your life to bring you to a place of brokenness before Him, where you’ve come to the end of yourself. That’s when we’re most able to receive His grace!