In The Transforming Power of the Gospel by Jerry Bridges, he says:
Impossible though it is for us to fulfill this standard, God has nevertheless called us to be holy as He is holy, and in order that we might understand what it means to be holy as He is holy, He has given to us His law (and here I am using law as a shorthand expression for all the moral will of God found throughout Scripture). God's law is both an expression of His moral will for us and also a reflection of His character.God is holy and never changes. Therefore His moral standard never changes. In order for human beings to enjoy relationship with God, we must be holy as He is. And so, just as Jerry Bridges said, God gave us His law so that we could know how to live in order to enjoy fellowship with God. Another word for this "giving" act of God is revelation. In revealing His law, God was revealing a bit of Himself.
There are essentially two sorts of revelation to be considered: general and special. General revelation is what we see in creation, while special revelation is what we have in the Bible. God has revealed His moral standard in both general and special revelation. In Romans 1-2, it is indicated that human beings are able to perceive God's revelation of Himself in creation, His "eternal power and divine nature" (Rom 1:19-20), and that human beings innately have a knowledge of God's moral standard built in to the conscience (Rom 2:15). Every human being to ever live has a sense of right and wrong, but note especially that all people who lived from Adam to Moses knew God's moral law.
Once we come to Moses, however, God published his moral law through special revelation. The very first text humans ever received from God was written by God Himself: the Ten Commandments. Following the idea that the law runs straight on through the whole Bible, these Ten Commandments are an explicit and specific recording of the same moral law that Adam had in his conscience. In other words, the moral standard that God published in creation He republished at Sinai.
What about all those other laws that God gave through Moses? In at least the Reformed tradition, there is understood to be three aspects to the law of Moses: moral, civil, and ceremonial. The civil aspect are laws similar to any government would have in order to uphold peace in a society, including laws for the punishment of criminals. The ceremonial aspect are laws regarding worship and sacrificial practices. The civil and ceremonial laws were new things that Adam never knew of, although they were based upon the moral law and the promise of the Messiah about which Adam did know. But now, just as that nation of Israel has been dissolved so the civil law of Moses is no longer in force. The ceremonial laws foreshadowed and pointed to Christ, so now that he has since come and fulfilled them those laws are not binding on us. The moral law, however, is as abiding as God's holy character.
There's a lot to get confused about in the law of Moses and the OT, but getting a feel for God's purpose in that covenant through Moses has helped me make more sense of the OT. The covenant through Moses was not given as a way for eternal salvation. The promise to one who kept all the law of Moses was not eternal life but long life in the land. It was a national covenant. The promise of eternal life, on the other hand, was announced to Abraham; all who believe that promise like Abraham did receive eternal life. Salvation of the human soul, even of those in national Israel, has always been by grace through faith in God's promise of a savior. God's primary purpose in this national covenant and in giving the law of Moses was to cause humanity to understand our total depravity, our inability to reach God's righteous standard, so that we would look to a savior. (See Gal 3:15-4:7.)
This leads to the so-called "three uses" of the abiding moral law. The first use of the law is to drive a sinner to his knees so that he sees his need for a savior. This is related to 1 Tim 1:8-11 where Paul says the law is for "lawless and disobedient" people. The second use is civil, so that evil acts receive punishment and thus, appealing to people's self interest, crime is deterred and relative peace established in a nation. Just as God's law says not to murder, so it is beneficial for a civil government to criminalize murder. The third use of the law is as a guide for the redeemed sinner, that as he desires to glorify and express gratitude to God he knows what to do.
Because they affirmed the abiding moral law, and since that moral law is summarized in the Ten Commandments, reformation traditions (Reformed, Reformed Baptist, Lutheran) all include teaching on the Ten Commandments in their catechisms. The first four commandments, or "first table" of the law, teach how to love God; the last six commandments, the "second table," teach how to love your neighbor. So the abiding use of the Ten Commandments is entirely consistent with Jesus' teaching on love as the greatest commandment.
For more on the three uses of the law, R.C. Sproul Jr. has a great article here.