Sin has more than one consequence.
On the one hand, it can break or hinder your fellowship with God. On the other hand, it can have consequences for you in this life.
The man who gets drunk at work, not only loses his intimacy with God—he can also get fired. And the woman who covets her neighbor’s things is not only blind to God’s good provisions for her—she can also live in self-induced misery.
In 1 John 1:9, believers are called to confess their sins:
“If we confess our sins, He is faithful and righteous to forgive us our sins and to cleanse us from all unrighteousness.”
Confession brings cleansing. It restores your fellowship with God. Confess the known sin and God cleanses you from all unrighteousness (both known and unknown). But 1 John 1:9 does not say that God will save you from the consequences of your actions.
When Israel refused to enter Canaan, God forgave them. But there were still consequences to pay:
Then the Lord said: “I have pardoned, according to your word; but truly, as I live, all the earth shall be filled with the glory of the Lord—because all these men who have seen My glory and the signs which I did in Egypt and in the wilderness, and have put Me to the test now these ten times, and have not heeded My voice, they certainly shall not see the land of which I swore to their fathers, nor shall any of those who rejected Me see it (Num 14:20-23, emphasis added).
They were forgiven, but had to die in the wilderness.
At first, you might think it is contradictory for God to say that Israel is pardoned and still punish them. But remember that forgiveness does not preclude suffering the natural consequences of your sins, or being disciplined by the Lord.
Imagine if a female teacher has a sexual relationship with an underage student. She may be able to find forgiveness, but she shouldn’t expect to keep her job or her teaching license!
Likewise, with God, confession and forgiveness restores the relationship, but doesn’t necessarily avert the consequences.