Galatians 3:21-22 (ESV) – 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.
If the Law is completely unnecessary for saving people, then why did God give it in the first place? Does the Law contradict the Gospel? It does not. The Law cannot save but it is crucial in bringing people to see their need to be saved. If the Law could give life then we could be made righteous by it. But the Law cannot give righteousness. The righteousness that God required comes only by faith in Jesus Christ.
The role of the Law in this is to show that we need something from outside of us if we are going to be able to stand before God. The Law “imprisoned everything under sin”. When, through the Law of God, we see that we are desperately lost, then we come to see that we need something great and powerful and loving to rescue us from our plight.
The Law acts like a diagnosis on our car. The mechanic must first determine the problem before he can begin to do what is required to fix the automobile. Telling us what the problem is does not fix it. The Law tells us what the problem is. Now that we see that, we see also Christ as the only solution to the problem.
So, the Law is not opposed to the Gospel. The Law is what drives us to the Gospel. But it cannot fix us up. The Law cannot be put to work to remedy the problem. That is beyond its scope and its ability. Do not try to make the law do what it cannot do. If you are trying to be saved by keeping God’s law you are asking the Law to do what it is designed not to do.
You may have never read the law of God at all. But that does not mean that you are not seeking to be right with God by keeping it. In Romans 10, Paul talks about people who try to establish their own righteousness. Everyone does this, no matter how much of God’s law they know. You are trying to save yourself by keeping the law if you can think of reasons about yourself why God should let you into His presence forever. If you can say “Here is why God should let me into heaven” and not refer to Jesus doing everything to save you and your faith in Him, then you are trying to keep the law. And it will fail you. You need Christ. The Law clearly shows that you do.