Firstly, the Catholic Sacrament of Confession is not some magical washing machine of the soul. The absolute conditions are 1) true sorrow for the sins and 2) a firm act of the will never to commit the sin again.
Of course, God is just and merciful. You can’t have one or the other; it’s both. He is the Creator of All and sets the rules and will punish you if you break them, but until the day you die He will be waiting and ready to give you the grace to repent and go to Him. Do you really think the good God wants anyone to go to Hell??? He died on the Cross so that all humans could share His Life and Happiness for all Eternity, but He does not destroy our human nature by taking away our free will and forcing us. He wants us to be of good will and freely choose to go to Him, which is why He gave us Confession.
However, God is not mocked, is not an idiot and cannot be cheated. To think that you can live how you please, deliberately disobeying God’s laws and so on, and presume that God will just grant you the free gift of His grace to repent on your deathbed, apart from being just ludicrous, is literally the grave sin of presumption. “A tree usually falls the way it is leaning”, and as such, deathbed conversions are extremely rare. If someone is habitually sinning for years, it’s pretty obvious that such a person is unlikely to even be willing to amend their life on their deathbed.