(Thanks to my Aunt Phyllis for inspiration on this one, and for a lifetime of being such a blessing of God's grace to me.)
Why did God give to Israel a law of commandments and ordinances He knew they wouldn't keep? "The LORD said unto Moses, I have seen this people, and, behold, it is a stiffnecked people" (Exodus 32:9)
The Apostle Paul answers the question in his epistle to the Galatians: "The law was our schoolmaster to bring us unto Christ, that we might be justified by faith" (Galatians 3:24). Rather than justify the Jews, the law was meant to reveal to them that they could never make themselves righteous by their own determination and effort. "By the deeds of the law there shall no flesh be justified in His sight; for by the law is the knowledge of sin" (Romans 3:20).
Paul wrote that "the law is holy, and the commandment holy and just and good" because its tenets and mandates express the character and nature of God Himself. This includes perfection - "as for God, His way is perfect" (II Samuel 22:31). Thus, if one is to relate to God by law, every command and ordinance must be completely fulfilled, from beginning to end. "Whosoever shall keep the whole law, and yet offend in one point, he is guilty of all" (James 2:10). We must of our own effort and determination to be as perfect as is God Himself.
This is highly problematic (yes, I know, that's a gross understatement! :) ). First, only God can be God, that is, only He can independently live according to His pristine standard of character and nature. "Thou art God alone" (Psalm 86:10). Furthermore, the heart of humanity apart from its Creator flows not with the current of perfect godliness, but with floodtide of sin and unrighteousness. "The heart is deceitful above all things, and desperately wicked" (Jeremiah 17:9). On both counts, the law could not succeed. That is, God will allow no other gods in His creation, which perfect fulfillment of the commandments would require. Nor can a sinful heart cleanse or remake itself by attempting to keep an outward code of spiritual and ethical behavior. Thus, there was never a hope that the law could make Israel or anyone else righteous in God's sight.
"What the law could not do, in that it was weak through the flesh, God sending His own Son in the likeness of sinful flesh, and for sin, condemned sin in the flesh that the righteousness of the law might be fulfilled in us who walk not after the flesh, but after the Spirit" (Romans 8:3-4).
The grace of God in the Lord Jesus enters and changes the heart of all who believe. "God hath sent forth the Spirit of His Son into your hearts" (Galatians 4:6). Grace involves an inside-out work of God, as it were, rather than the outward faithfulness demanded by the law. The Spirit of the Lord Jesus deals with the root rather than the fruit, beginning the work of genuine righteousness in us by inhabiting the very depths of our spiritual being. The law of commandments and ordinances bows before "the law of the Spirit of life in Christ Jesus" when we trust in Christ rather than our own deluded attempts to be and do what we can never independently fulfill (Romans 8:2).
The law demands; grace provides. The law cries to us from without; grace sends "the Spirit of His Son into your hearts, crying Abba Father" (Galatians 4:6). The law mandates perfection from the imperfect; grace freely imputes the perfection of the Lord Jesus to the trusting heart, while also assuring of complete perfection in the future to come. "He which hath begun a good work in you will perform it until the day of Jesus Christ" (Philippians 1:6). On and on the list could go of the impossibilities of the law, and the the guarantees of grace. Most of all, the grace of God in the Lord Jesus births love within the trusting heart. The law could never accomplish such a blessed wonder because the love of God must be received before true love for God can be born, assimilated and expressed in us. "The love of God is shed abroad in our hearts by the Holy Spirit which is given unto us" (Romans 5:5).
Let us always thank God for the law of Moses. It was and is a blessed educator of our hearts as it tells us necessary things about both the Divine and the human. It could not save, of course, but it was never meant to do so. No, the law tells us the truth that God is God, and we are not. Such light prepares us to the glorious salvation whereby we exchange the labors of our hands for the gaze of our hearts...
"Looking unto Jesus, the author and finisher of our faith."