"5"If a man is righteous and does what is just and right-- 6if he does not eat upon the mountains or lift up his eyes to the idols of the house of Israel, does not defile his neighbor's wife or approach a woman in her time of menstrual impurity, 7does not oppress anyone, but restores to the debtor his pledge, commits no robbery, gives his bread to the hungry and covers the naked with a garment, 8does not lend at interest or take any profit, withholds his hand from injustice, executes true justice between man and man, 9walks in my statutes, and keeps my rules by acting faithfully--he is righteous; he shall surely live, declares the Lord GOD" (Ezekiel 18:5-9)
And if the wicked (v.10-13) repents and turns to God, his or her sins will be forgiven (v.21-23).
"21"But if a wicked person turns away from all his sins that he has committed and keeps all my statutes and does what is just and right, he shall surely live; he shall not die. 22None of the transgressions that he has committed shall be remembered against him; for the righteousness that he has done he shall live. 23Have I any pleasure in the death of the wicked, declares the Lord GOD, and not rather that he should turn from his way and live?" (Ezekiel 18-21-23)
But if the righteous (v.5-9) departs from faith, he will be punished (v.24)
24But when a righteous person turns away from his righteousness and does injustice and does the same abominations that the wicked person does, shall he live? None of the righteous deeds that he has done shall be remembered; for the treachery of which he is guilty and the sin he has committed, for them he shall die. (Ezekiel 18:24)
Ezekiel 18 ends with a call to repent and turn to God with "a new heart and new spirit", which seems to echo the New Covenant (Ezekiel 37:14 and Jeremiah 31:33)
30"Therefore I will judge you, O house of Israel, every one according to his ways, declares the Lord GOD. Repent and turn from all your transgressions, lest iniquity be your ruin.[c] 31Cast away from you all the transgressions that you have committed, and make yourselves a new heart and a new spirit! Why will you die, O house of Israel? 32For I have no pleasure in the death of anyone, declares the Lord GOD; so turn, and live." (Ezekiel 18:20-32)
It's interesting that Ezekiel's audience considered God's way of life and punishment as unjust (v.25-27) in the OT, which appears to be solved by Christ's propitiatory death in the NT (Romans 3:21-26).
21But now the righteousness of God has been manifested apart from the law, although the Law and the Prophets bear witness to it-- 22the righteousness of God through faith in Jesus Christ for all who believe. For there is no distinction: 23for all have sinned and fall short of the glory of God, 24and are justified by his grace as a gift, through the redemption that is in Christ Jesus, 25whom God put forward as a propitiation by his blood, to be received by faith. This was to show God's righteousness, because in his divine forbearance he had passed over former sins. 26It was to show his righteousness at the present time, so that he might be just and the justifier of the one who has faith in Jesus. (Romans 3:21-16)