'Righteousness' in the Bible
Righteousness will be ours if we are careful to follow every one of these commands before the Lord our God, as He has commanded us.’
When the Lord your God drives them out before you, do not say to yourself, ‘The Lord brought me in to take possession of this land because of my righteousness.’ Instead, the Lord will drive out these nations before you because of their wickedness.
You are not going to take possession of their land because of your righteousness or your integrity. Instead, the Lord your God will drive out these nations before you because of their wickedness, in order to keep the promise He swore to your fathers, Abraham, Isaac, and Jacob.
Understand that the Lord your God is not giving you this good land to possess because of your righteousness, for you are a stiff-necked people.
Be sure to return it to him at sunset. Then he will sleep in it and bless you, and this will be counted as righteousness to you before the Lord your God.