ויהי בשׁלח פרעה את העם ולא נחם א-להים וכו’ י
And it came to pass, when Pharaoh had let the people go, God did not lead them by way of the land of the Philistines
Exodus 13:17
The Midrash Rabbah deduces that “ויהי” (and it came to pass) is an expression of lament (לשון צער), and offers many opinions about who had reason to cry “woe” as the people left Egypt. But our master explains that it is the Torah that raised her voice and cried “woe,” because, until they were chased out of Egypt by Pharaoh with a strong arm, the Children of Israel did not want to leave Egypt, preferring to stay in that dreary valley. God therefore “did not lead them [out of Egypt] by way of the land of the Philistines, although that was near, for God said, lest the people repent upon seeing war, and return to Egypt.” (שביבי אש)
שם שם לו חק ומשפט ושם נסהו ויאמר אם שמוע תשמע לקול ד”א והישר בעיניו תעשה והאזנת למצותיו ושמרת כל חקיו
There the Lord made for them a statute and an ordinance . . . saying, “If you will diligently hearken to the voice of the Lord your God, and do what is right in His eyes, and give heed to His commandments, and keep all His statutes. . .”
Exodus 15:25-26
Rashi explains: At Marah he gave them a few sections of the Torah so that they might engage in the study thereof, in particular, the sections concerning the Sabbath, the red heifer (פרה אדומה), and the laws of justice (דינים).
Our master gave a twofold reasons for these three sections to be taught. The Eternal wanted to provide the Israelites at Marah with one representative commandment of each of the three categories of commandments in the Torah. The three categories are the commandments of reason (מצות השכליים), the commandments of understanding (מצות השמע), and the statutes (חוקים). They were informed about the commandments at Marah . Just as a prospective convert is informed about some of the easy commandments and some of the difficult commandments, so that the convert may be able to draw inferences from those commandments about the other commandments. The commandments of reason are those that we already know ourselves by way of our own reason, and which, even without being commanded to observe them, we could have, on our own, understood that they ought to be kept. Corresponding to such commandments, God instructed them in the laws of justice (דינים) which also are based on reason.
Besides this category, there are the commandments of understanding (מצות שמע), which are commandments that we would not ourselves have known without being commanded to observe them, but, once we do hear about them, we can easily find reason to understand and praise them. And corresponding to this category, God commanded them to observe the Sabbath, explaining that the reason for observing the Sabbath is that it is an eternal sign of the covenant between God and the people of Israel. Finally, the statutes (חוקים) are those commandments, which our understanding, even after we hear about them, does not comprehend. And corresponding to this category, God gave them the law of the red heifer, whose rationale is inaccessible to us.
This explains why the Scripture says (Exodus 15:26): “אם שמע תשמע לקול ה’ א-לוהך” (if you will diligently hearken to the voice of the Lord your God) which is a general statement encompassing the entire Torah: its laws of justice (משפטיה), its statutes (חקותיה), and its testimonies (עדותיה). The Scripture then mentions specifically “והישר בעיניו תעשה” (and will do that which is right in His eyes) referring to the commandments of reason that they were able to know would be right in the eyes of God even without being commanded to do so. Next the Scripture says “והאזנת למצותיו” (and you shall give heed to His commandments), referring to the commandments of understanding, which we understand not upon first hearing, but only afterwards. Finally, the Scripture says, “ושמרת כל חקיו” (and keep all His statutes), referring to the commandments whose rationale and purpose are hidden, and whose manner of observance is distant. (שביבי אש)