Why, then, was the law given? It was given alongside the promise to show people their sins. But the law was designed to last only until the coming of the child who was promised. God gave his law through angels to Moses, who was the mediator between God and the people.
Now a mediator is helpful if more than one party must reach an agreement. But God, who is one, did not use a mediator when he gave his promise to Abraham.
Is there a conflict, then, between God’s law and God’s promises? Absolutely not! If the law could give us new life, we could be made right with God by obeying it.
References for Galatians 3:21
But the Scriptures declare that we are all prisoners of sin, so we receive God’s promise of freedom only by believing in Jesus Christ.
Before the way of faith in Christ was available to us, we were placed under guard by the law. We were kept in protective custody, so to speak, until the way of faith was revealed.
Let me put it another way. The law was our guardian until Christ came; it protected us until we could be made right with God through faith.
And now that the way of faith has come, we no longer need the law as our guardian.