God’s Law was given to demonstrate that we are different from Him. He does not murder, He does not bear false witness, He does not covet. We do. The Law leads us to understand that we are not like Him and if we want to be in His presence we have to have to be changed. Galatians 3:24 tells us the Law leads us to faith in Christ.
So think of it. If the Law were written on the hearts of the people. The nature and character of God would be written on their hearts. They would not need someone to tell them about God. His nature is in their hearts.