"Why the Law then? It was added because of transgressions, having been ordained through angels by the agency of a mediator, until the seed would come to whom the promise had been made. Now a mediator is not for one party only; whereas God is only one. Is the Law then contrary to the promises of God? May it never be! For if a law had been given which was able to impart life, then righteousness would indeed have been based on law. But the Scripture has shut up everyone under sin, so that the promise by faith in Jesus Christ might be given to those who believe." (Galatians 3:19-22)One of the main ideas that Paul continually tries to drive home to us is that the Law was never meant to be our pathway to righteousness. As good, wholesome, and righteous as the law was, it was never able to produce righteousness in its hearers or doers. This is not because of some defect in the Law but rather because of the defect in us. The sin that lies within us shuts us out from true obedience to the Law and renders the law as death to us rather than life and peace. The Law cannot give us life and it cannot make us righteous.
The second point Paul is trying to make is that the law was extended to man through a mediator while His promise to man was announced in person. The law places us under the custodianship of a mediator, that being the Law. Our access to God is mediated by our obedience to the law. So thorough was that law that it regulated every aspect of civil and personal life. Even our conduct in the bathroom is specified under the law. "You shall also have a place outside the camp and go out there, and you shall have a spade among your tools, and it shall be when you sit down outside, you shall dig with it and shall turn to cover up your excrement." (Deuteronomy 23:12-13) The presence of God in their midst was mediated by their obedience lest God, "see anything indecent among you" (Deuteronomy 23:14) and turn away from them. However, our life under the promise of God is not mediated by anything or anyone. God made it personally to Abraham and we are personal inheritors of the same promise. The law no longer mediates the presence of God, rather we are free to know and love Him directly, personally, and inanimately apart from obedience to the law.
So why the law? Paul says it was given because of transgressions. It is interesting that, even before the law came, we still transgressed the law, we just did not know it. People were still sinning even without the law. Paul speaks of those who sinned but "had not sinned in the likeness of the offense of Adam" (Romans 5:14) in that they had not violated a definite command of God. The law came to make us aware of sin, to show us what sin was, and to counsel us how to live righteously according to the ways of God. Paul says that the law came so that sin "might be shown to be sin by effecting my death through that which is good, so that through the commandment sin would become utterly sinful." (Romans 7:13) The law came so that sin might be shown to be sinful so that we might hopefully avoid it personally and in our relationships with one another. For the next two thousand years the law would be our intermediary, teaching us how to live and mediating our relationship with God, while we all waited for His promise to come true; while we all waited for His Son. The law stood in between, between the promise and the fulfillment. However, once the promise was fulfilled so was the purpose and usefulness of the law. We are no longer under the law because we are now under God's promise.