Didn't Paul say that if not for the law we would not know what sin is and James said if we break one law it's the equivalent of breaking the entierty of the law.
Yes, the law's purpose was to symbolically show man he falls short of a standard God has, of morality and spiritual purity. Hebrews gives us a clue that the ritual and ceremonial law was a symbolic reality of spiritual truths, so that, for example, unclean and clean animals were representative of something more than just that some animals were bad somehow. It was not a mistake, nor was it an indicator of morality, it was a symbolic rite. The way Paul often uses the law though is emphasizing the moral aspects of it, loving God and neighbor, and living the way one ought.
The two verses you quote here are very important, because they are meant to show the height and purity of God's standard that made the death and blood of Christ necessary—a standard of spiritual perfection no human being can attain, yet God requires. This is why by any means necessary we must be found
in Christ as our righteousness. People sometimes don't like the injustice of getting righteousness as a free gift, so they do as Paul said in Galatians 2, they "rebuild that which [God in Christ] destroyed" as a system of self justification. This is, effectively, to reduce and demean the strength and extent of the Work of Christ, for now something is accompanied along with it that is meritorious.
But what of all the preached moralism in the Bible as works that we do? A grace preacher sees that as the new life Christ produces in us by his Work, not as something we could ever decide to do in our willpower, or accomplish through our effort and strength. We
die to the idea of a righteousness attained this way, when we see our old selves judged and crucified in Christ. Paul says if we do the greatest moral deeds, but have no love, it profits us nothing. How can we judge how much real love we have? To me that is a conundrum. When I look around at the human race, even the greatest love seems tainted with some wrong motivations. Where do we find the truest, purest love? We can only see it in the truest, purest creature making the purest sacrifice; only Christ contains true love.
Thus the purpose and function of the law is always to show us our spiritual bankruptcy which is meant to drive us to faith in grace bringing righteousness and sanctification as a free gift working in us by another person's power, the power of the Holy Spirit, and not the power of our own selves, and the resources we contain. Sadly, what often happens is, because people realize they can't throw grace out altogether because everybody needs some forgiveness and help, they end up mixing self-works with God's grace and producing a kind of hybrid Gospel where Christ does some of it, and we do the rest. If we, however, are not trusting completely in Christ, then logically we must be trusting in ourselves. The sanctification in our life does not ever come from our determined efforts to make it happen, but our choice to believe and trust in God to do through Christ in us what we could never.
The other side of the ditch to fall in is "sloppy grace" where teachers tell us we don't need that sanctification, but we can just be happy
without a true faith that God actually will sanctify us, and hence be happy living in sin. We can't limit what miracle God can do in our life, regarding sanctification, that he might truly make us holy, which so often in our condemnation and weakness, feels impossible; but we can't allow our pride to think that without the Cross-work applied to us, we could achieve pure moral works or attain in our own power the perfect righteousness God demands. So God is at work in us, and this is the emphasis of the New Covenant. Even in the Old Covenant I believe there was available through a symbolism of the coming Christ a righteousness that comes by faith and accompanying grace—and when we see the law in any sense, moral or ceremonial, as a means God put in place to show us how to be righteous, we stumble at the stumbling stone, because it removes the necessity of Christ dying and rising again on our behalf.
The law was always meant to show us our need of grace.