וַיְהִי בְּשַׁלַּח פַּרְעֹה אֶת-הָעָם וְלֹא נָחָם אֱלֹקִים וכו'
And it came to pass, when Pharaoh had let the people go, G-d did not lead them by way of the land of the Philistines (Exodus 13:17)
In Midrash Rabbah it is deduced that "וַיְהִי" (and it came to pass) is an expression of lament (לשון צער). The Midrash offers many explanations of who it was that cried "woe" the people left Egypt. But it appears to our master that it is the Torah that raised her voice and cried "woe," because, until Pharaoh chased them out with a strong hand, the children of Israel did not want to leave Egypt, but preferred to stay in that murky valley. G-d therefore "did not lead them by way of the land of the Philistines, although that was near, for G-d said, lest the people repent when they see 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 G-d, 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 in order that they might engage in the study thereof; namely, the sections concerning the Sabbath, the red heifer (פרה אדומה), and the laws of justice (דינים).
Our master gave a twofold reason for the choice of these three sections. The Eternal wanted to provide the Israelites at Marah with one commandment as an example of each of the three categories of commandments that are 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 might be able to draw some inference from those commandments about the other commandments. The commandments of reason are those that we already know ourselves from our own reason, and which, even had we not been commanded to observe them, we ourselves would have understood ought to be kept. Corresponding to these commandments, G-d instructed them in the laws of justice (דינים) which are derived from reason. Then there are the commandments of understanding (מצות שמע) which are commandments that we would not have known ourselves without being commanded to observe them, but upon hearing them, we find reason to understand and praise them. And corresponding to this category, G-d commanded them to observe the Sabbath while explaining to them that reason for its observance is that it is an eternal sign of the covenant between G-d and the people of Israel. And the statutes (חוקים) are those commandments which our understanding is too limited to comprehend even after we have heard them. And corresponding to this category, G-d gave them the law of the red heifer, whose ways are hidden from us.
This explains why the Scripture says (Exodus 15:26): "If you will diligently hearken to the voice of the Lord your G-d" which is a general statement encompassing the entire Torah, its laws of justice (משפמיה), statutes (חקותיה), and 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 G-d even if they had not been commanded accordingly. Next the Scripture says "and you shall give heed to His commandments," refering to the commandments of understanding which we first hear and understand only afterwards. Finally, the Scripture says, "and keep all His statutes," referring to the commandments whose reason and purpose are hidden, and whose manner of observance is distant.