Abraham believed Yahweh, and he credited it to him as righteousness.
Perhaps our idea of righteousness is not the same as God's.
In His kingdom we are righteous when we believe in Him and take Him at His word.
How many times in my life have I tried to present myself as righteous to God, but probably more truthfully, tried to present myself as righteous to other people. My Bible reading, my spiritual conversations, my church attendance, my acts of service, my clothing choices, who I am seen with, don't count for anything and do not cause God to declare me righteous. But if I believe what He says then I am righteous.
God doesn't look at outward appearances, He looks at the heart. He knows the motives behind our actions and knows whether we are living a life founded on belief in Him.
Listen to the words of Jesus in John 6;28-29 that confirm this message;
"Then they asked him 'What must we do to do the works God requires?' Jesus answered, 'The work of God is this: to believe in the one he has sent.'"