OK, so if the Ten Commandments and all the other laws of Moses weren't designed to give us eternal life, then what were they designed for?
The Law was added on to Abraham's covenant because of human sin (v. 19). Even the adding-on part was meant to be temporary. Once Jesus came -- the true Seed to whom God promised Abraham's covenant -- the Law was "peace, out."
God spoke the Law to Moses through angels, then entrusted the Law to Moses rather than give it to the Jews directly. You can see from this verse how superior Jesus is to Moses and the law! Moses brought us damnation, but Jesus brought us salvation. Moses was a sinful go-between, but Jesus was the one-and-only Son of God. Moses was handed the Law by angels, but Jesus came forth straight from the bosom of the Lord., who is one Lord.
Jesus and his Gospel is superior to Moses and the Law in every way.
Did the Law contradict the Gospel? Certainly not! In fact, if it was possible for any law to give a sinner everlasting life, Moses' Law would have been that law (v. 21). But the Law's role was that of a jailer, not a pardoner,
The Law defines sin. By doing so, it condemns sin. As a result, the Law locked up the whole human race under guilt and condemnation. That wasn't the Law's fault. That was our fault.
Like a prisoner being processed into prison (3:23), the Law empties out your pockets, strips off every stitch of your clothing, and leaves you standing there naked . It leaves you nothing. The Law leaves you with no other way to be saved than as a gift, received by believing the offer.
The Law was also like a set of "school rules", laid down on the school by the headmaster. God is the headmaster. The Jews were to live in Gods school, under Moses' system of rules, until Jesus Christ came and achieved redemption (24).
Christ fulfilled the Law's requirements. He did this by perfectly living it himself, then fulfilled its penalty for sin by dying. Now that redemption has been accomplished, the Law steps aside. Its work is complete. Christ didn't annul the Law, he fulfilled it.
Is someone who teaches that we must keep the laws to be saved ignorant of the Gospel? Yes. But they are also deeply ignorant of the Law! Those who claim to champion the Law are the ones who understand it the least. Such people are ignorant of what the Law required (perfection). They don't know why the Law was given (to define sin). They don't even know that the Law ended (when Christ died).
This is the ironic thing: the legalist doesn't really understand the Law!