Why then the law? It was added because of transgressions, until the offspring should come to whom the promise had been made, and it was put in place through angels by an intermediary. Now an intermediary implies more than one, but God is one.
Is the law then contrary to the promises of God? Certainly not! For if a law had been given that could give life, then righteousness would indeed be by the law. But the Scripture imprisoned everything under sin, so that the promise by faith in Jesus Christ might be given to those who believe.
Now before faith came, we were held captive under the law, imprisoned until the coming faith would be revealed. So then, the law was our guardian until Christ came, in order that we might be justified by faith. But now that faith has come, we are no longer under a guardian … (Galatians 3:19-25 ESV)
"The Law with its function does contribute to justification—not because it justifies, but because it impels one to the promise of grace and makes it sweet and desirable. Therefore we do not abolish the Law; but we show its true function and use, namely, that it is a most useful servant impelling us to Christ ... Therefore the principal purpose of the Law in theology is to make men not better but worse; that is, it shows them their sin, so that by the recognition of sin they may be humbled, frightened, and worn down, and so many long for grace and for the Blessed Offspring." ~ Martin Luther (Galatians 26:315, 327)