"Now therefore why tempt ye God, to put a yoke upon the neck of the disciples, which neither our fathers nor we were able to bear?" - Acts 15:10
In Acts chapter 15, we find that a sect had formed that was teaching the Christian Gentiles that they needed to be circumcised per the Law. Peter, James, Paul, Barnabas, Jude, and Silas began writing letters and traveling to the various churches in order to reinforce the true Gospel which is that it is only by His grace that we can be saved.
The Apostles knew that nobody can keep the Law. Not them, Gentile converts, or their forefathers "were able to bear". That then begs the question of why God gave the Law in the first place.
By obeying the Law, the other nations would see how blessed Israel was and would seek the Giver of all blessings (Deut. 4:5-9).
However, the Law did not have to be given in order for the world to see who the true God is.
Prior to the Law, there were those that walked with God (see Dispensations for examples). When God was pronouncing judgment upon Egypt through the ten plagues, the Egyptians and local Gentiles saw that the God of the Hebrews was real (Exodus 8:19, 12:35-36, 18:10-11). God made Himself known in many ways without His Law.
After the Israelites fled Egypt, Pharaoh unleashed his army to wipe out the Jews. This culminated at the Red Sea. When the Israelites saw Pharaoh's approaching army they said to Moses "because there were no graves in Egypt, hast thou taken us away to die in the wilderness? wherefore hast thou dealt thus with us, to carry us forth out of Egypt?" (Exodus 14:11). God parted the Red Sea and delivered them. After more traveling, the Israelites complained to Moses and said "would to God we had died by the hand of the Lord in the land of Egypt, when we sat by the flesh pots, and when we did eat bread to the full; for ye have brought us forth into this wilderness, to kill this whole assembly with hunger" (Exodus 16:3). One chapter later, again they complained to Moses "wherefore is this that thou hast brought us up out of Egypt, to kill us and our children and our cattle with thirst?" (Exodus 17:3).
God did not destroy or punish the Israelites. He provided for them! When God promised Abraham and his descendants the land of Israel, God did not state that the Jews would inherit the land based upon their performance. He gave them that land because of His goodness.
So, then, how did the Law come about? Why was it given? After the Israelites complained about food, when God was providing for them He gave them instructions in order to see if they would walk in His Law (16:4). Notice that the Law had not been given yet. The Israelites failed to follow His instructions (16:20), but they were not punished. There were no consequences because they were relying upon His grace!
In chapter 19, God told the people that if they would keep His covenant that they would be a blessed nation. What was His covenant? Circumcision. That was it. This covenant was established with Abraham in Genesis 17:4-14. The Israelites, in their pride, exchanged His unmerited grace for works-based grace. They went from God's protection and provision to 3,000 slain for giving into idol worshiping (Exodus 32).
God was gracious and wanted His people to talk to Him. He would even allow people to bargain with Him (Genesis 18:19-33)! Believing that we can earn His blessings and depend upon our own goodness is nothing other than pride. It was through the pride of the Jews that they received the Law. King David wrote in Psalm 10:4 "the wicked, through the pride of his countenance, will not seek after God: God is not in all his thoughts". Pride causes us to focus inward instead of outward even though our own righteousness is nothing next to God's (Isaiah 64:6).
When Israel desired to be under the Law they fell from grace. The Jews were not under any bondage, but put themselves into bondage by desiring the Law. Look at what the Apostle Paul says in Galatians 5:1-4
"Stand fast therefore in the liberty wherewith Christ hath made us free, and be not entangled again with the yoke of bondage. Behold, I Paul say unto you, that if ye be circumcised, Christ shall profit you nothing. For I testify again to every man that is circumcised, that he is a debtor to do the whole law. Christ is become of no effect unto you, whosoever of you are justified by the law; ye are fallen from grace."
Israel had a chance to change their minds and remain under His grace. They heard the Law (Exodus chapters 19-24), and yet in their pride, they still said "all that the Lord hath said will we do, and be obedient" (Ex. 24:7). The next verse is when the new covenant was established. It is important to understand that until Exodus 24:8, the Jews were still under the Abrahamic covenant. To establish a covenant, there must be a death involved. There must be the shedding of blood (Heb. 9:16-18).
"And Moses took the blood, and sprinkled it on the people, and said, Behold the blood of the covenant, which the Lord hath made with you concerning all these words." - Exodus 24:8
God was still gracious and still loved His people even though they could not follow His Law. In Psalm 78, Asaph gives the history of Israel. Notice that he shows what God did for His people even though they kept turning away from Him both prior to the Law and after the giving of the Law. Even though the Israelites were constantly deserving of His wrath, He often turned away from meting out the deserved punishments because "they were but flesh" (Psalm 78:39). In Psalm 86:15, the Psalmist writes "but thou, O Lord, art a God full of compassion, and gracious, long suffering, and plenteous in mercy and truth".
The Law revealed His righteousness and how depraved man is. It was only through His mercy that the Jewish nation was established (Gen. 17:4-14) and it was only through His mercy that God provided a permanent sacrifice for sin for Jew and Gentile alike (Heb. 10:10). It was through His mercy that He promised the coming of Jesus shortly after the Law was given (Deut. 18:15-18). Jesus, God Himself, is the only One that could ever fulfill the Law (Matt. 5:17).