Why, then, was the law given at all? It was added because of transgressions until the Seed to whom the promise referred had come. The law was given through angels and entrusted to a mediator. A mediator, however, implies more than one party; but God is one.
Is the law, therefore, opposed to the promises of God? Absolutely not! For if a law had been given that could impart life, then righteousness would certainly have come by the law. But Scripture has locked up everything under the control of sin, so that what was promised, being given through faith in Jesus Christ, might be given to those who believe.
Before the coming of this faith, we were held in custody under the law, locked up until the faith that was to come would be revealed. So the law was our guardian until Christ came that we might be justified by faith. Now that this faith has come, we are no longer under a guardian.
So in Christ Jesus you are all children of God through faith, for all of you who were baptized into Christ have clothed yourselves with Christ. There is neither Jew nor Gentile, neither slave nor free, nor is there male and female, for you are all one in Christ Jesus. If you belong to Christ, then you are Abraham’s seed, and heirs according to the promise.
Galatians 3:19-29
Paul's old understanding of the past
Paul old understanding was that God gave the law because Jews could obey it. "Now what I am commanding you today is not too difficult for you or beyond your reach. [...] No, the word is very near you; it is in your moth and in your heart so you may obey it." (Deuteronomy 30:11, 14)
He also believed that his obedience to the law was perfect. "If someone else thinks they have reasons to put confidence in the flesh, I have more: circumcised on the eighth day, of the people of Israel, of the tribe of Benjamin, a Hebrew of Hebrews; in regard to the law, a Pharisee; as for zeal, persecuting the church; as for righteousness based on the law, faultless." (Philipians 3:4-6)
The Mosaic law has sacrificial laws of atonement, which meant that if you sinned, you had to make a sacrifice to atone for it. The law was given so that the people could do it and be saved.
Paul's new understanding of the past
When Paul saw the risen Jesus, his world changed-- because if God raised Jesus from the dead, then His followers were right, and Jesus died for our sins. And if He did, then righteousness cannot be gained by the law. "... if righteousness could be gained through the law, Christ died for nothing." (Galatians 2:21)
Paul's doctrine of sin was not obvious to him but was revealed to him in Jesus. His new understanding was that the law was given to show we couldn't do it. "For if a law had been given that could impart life, then righteousness would certainly have come by the law. But Scripture has locked up everything under the control of sin..." (Galatians 3:21-22)
Paul's new understanding of the future
With the coming of Jesus, Jews like Paul are no longer under the law.
"So in Christ Jesus you are all children of God through faith, for all of you who were baptized into Christ have clothed yourselves with Christ. There is neither Jew nor Gentile, neither slave nor free, nor is there male and female, for you are all one in Christ Jesus. If you belong to Christ, then you are Abraham’s seed, and heirs according to the promise." (3:26-29)
Paul's understanding of the future involves a new Creation ("neither Jew nor Gentile, neither slave nor free, nor is there male of female"), a new kind of community not defined by race or social class or gender ("children of God through faith"), and a new way of life ("all of you who are baptized into Christ have clothed yourselves with Christ").
If you want to look like Jesus, remember that He was the one who, being in very nature God, took the nature of a servant, humbled Himself by becoming obedient to death on a cross-- all for love of us.