The Old Covenant (made with Israel at Mount Sinai when God gave the Ten Commandments) failed because it was based on the promise of the people to obey who then never fulfilled the conditions of the Old Covenant by obeying as a nation.
Hence as Paul writes in the Book of Hebrews the New Covenant (which is the same as the Old Covenant) is based upon better promises. He then goes on to quote the passages of Scripture in the Old Testament where God promises to write His law upon the heart of those willing to enter into a covenant relationship with God.
Please read Luke 10:25 – 37 and the entire chapter in Christ’s Object Lessons written by Ellen G. White entitled: The Good Samaritan very carefully.
Matt. 22:34 – 40:
“But when the Pharisees had heard that he had put the Sadducees to silence, they were gathered together. Then one of them, which was a lawyer, asked him a question, tempting him, and saying, Master, which is the great commandment in the law? Jesus said unto him, Thou shalt love the Lord thy God with all thy heart, and with all thy soul, and with all thy mind. This is the first and great commandment. And the second is like unto it, Thou shalt love thy neighbour as thyself. On these two commandments hang all the law and the prophets.”
Notice that the neither lawyer in Luke chapter 10 nor Jesus in Matt. chapter 22 choose to quote from the Ten Commandments.
Jesus has just quoted Deut. 6: 5; & 10: 12 (here is Deut. 30:6: “And the LORD thy God will circumcise thine heart, and the heart of thy seed, to love the LORD thy God with all thine heart, and with all thy soul, that thou mayest live.”) along with Lev. 19:18cf and then He states: “On these two commandments hang all the law and the prophets.”
By Jesus’ statement that all the law – which includes the Ten Commandments which is also the Old and New Covenants – and the prophets hang upon these two commands found in Deut. 6:5 and Lev. 19:18cf makes these Two commandments the Spirit Of the Law while the Ten Commandments are the Letter of the Law.
Now the Letter of the Law can only condemn the sinner to eternal death it cannot give life thus salvation does not come through keeping the letter of the law. Which is why Paul also wrote in 2Cor. 3:6:
“Who also hath made us able ministers of the new testament; not of the letter, but of the spirit: for the letter killeth, but the spirit giveth life.”
On the other hand (just as Paul also writes in the very same verse) the Spirit does indeed give life and through a personal intimate relationship with Christ the sinner is empowered by the Holy Spirit to keep the Spirit of the Law thus fulfilling the letter of the law.
Both Paul and James write:
“For all the law is fulfilled in one word, even in this; Thou shalt love thy neighbour as thyself.” Gal. 5:14
“If ye fulfil the royal law according to the scripture, Thou shalt love thy neighbour as thyself, ye do well: But if ye have respect to persons, ye commit sin, and are convinced of the law as transgressors. For whosoever shall keep the whole law, and yet offend in one point, he is guilty of all. For he that said, Do not commit adultery, said also, Do not kill. Now if thou commit no adultery, yet if thou kill, thou art become a transgressor of the law. So speak ye, and so do, as they that shall be judged by the law of liberty. For he shall have judgment without mercy, that hath shewed no mercy; and mercy rejoiceth against judgment.” James 2:8 – 13
What this means is that until the Spirit of the Law (which is unselfish and unconditional love towards God and our fellow human beings) is written upon the heart the sinner cannot keep the letter of the law. Hence anyone who focuses upon the “Letter of the Law” while ignoring the “Spirit of the Law will fail in keeping the “letter of the Law”, fall short of the Glory of God and find themselves standing with the rest of the wicked outside the New Jerusalem eternally lost.