The God of Abraham, Isaac, and Jacob gave the Law of Moses.
But no one can fulfill the Law of Moses perfectly.
To God, no one is righteous before His eyes, because of our sins and shortcomings:
"The Lord has looked down from heaven upon the sons of men
To see if there are any who understand,
Who seek after God.
They have all turned aside, together they have become corrupt;
There is no one who does good, not even one." (Psalm 14:2-3)
It is not possible for the blood of animals to atone for the sins of the soul (Hebrews 10:4). And no one can even keep the Ten Commandments perfectly. (Have you ever coveted? Have you ever quarreled with your parents? Have you ever lied [bore false witness]? Then you have broken the Commandments.)
So the Messiah (Jesus) came to earth to atone for our sins Himself. The perfect Son of God died in place of the unrighteous so that we can be made perfect through faith in Him.
"Therefore the Lord Himself will give you a sign. Behold, the virgin shall conceive and bear a Son, and shall call His name Immanuel [God with us]." (Isaiah 7:14)
"But He was pierced through for our transgressions,
He was crushed for our iniquities;
The chastening for our well-being fell upon Him,
And by His scourging we are healed.
All of us like sheep have gone astray,
Each of us has turned to his own way;
But the Lord has caused the iniquity of us all
To fall on Him." (Isaiah 53:5-6)
See Isaiah 52 and Isaiah 53.
https://www.bible.com/bible/100/ISA.53.NASB1995
Jesus lived a perfect life (keeping all the Law) and died for our sins in our place. No one can keep the Law perfectly. No one is justified before a holy and perfect God. We need a Savior to save us from our sins. So we are credited with Jesus' righteousness and forgiven of our sins if we believe in Him.
Everyone living before Jesus came who hoped for a Messiah were credited with His righteousness. And if anyone believes in Him now, he will also be credited with His righteousness.
Abraham believed and it was credited to him as righteousness:
"Then he believed in the Lord; and He reckoned it to him as righteousness." (Genesis 15:6)
So we also live by faith.
"But the righteous will live by his faith." (Habakkuk 2:4)