(17) Be sure to keep the commandments, decrees, and laws that the LORD your God has enjoined upon you. (18) Do what is right and good in the sight of the LORD, that it may go well with you and that you may be able to possess the good land that the LORD your God promised on oath to your fathers, (19) and that all your enemies may be driven out before you, as the LORD has spoken. (20) When, in time to come, your children ask you, “What mean the decrees, laws, and rules that the LORD our God has enjoined upon you?” (21) you shall say to your children, “We were slaves to Pharaoh in Egypt and the LORD freed us from Egypt with a mighty hand. (22) The LORD wrought before our eyes marvelous and destructive signs and portents in Egypt, against Pharaoh and all his household; (23) and us He freed from there, that He might take us and give us the land that He had promised on oath to our fathers. (24) Then the LORD commanded us to observe all these laws, to revere the LORD our God, for our lasting good and for our survival, as is now the case. (25) It will be therefore to our merit before the LORD our God to observe faithfully this whole Instruction, as He has commanded us.”
שמור תשמרון את מצות ה’ אלו-היכם, “be certain to observe the commandments of the Lord your G’d.” ... By keeping the commandments you will do what is good and right in the eyes of the Lord. This is why Moses adds the words למען ייטב לך, “so that it will prove to be good for you.” It stands to reason that people who are loyal to their king and observe his laws will be recognized as such and be suitably rewarded. The same holds true when you serve the King of Kings in even increased measure. After all, the whole reason G’d issues commandments to His creatures is for their benefit as repeated in 10,13.
We may divide the commandments mentioned in our verse into three major groups: 1) מושכלות, laws recommending themselves to our intelligence; 2) מקובלות, laws based on our history; 3) חקים, statutes, the meaning of which transcends our ability to understand.
When Moses speaks of מצות ה’ he has in mind mostly laws governing inter-personal and inter-societal relationships, the ones generally referred to as משפטים. These are the ones we termed מושכלות, accessible to our intellect.
When Moses writes: ועדותיו, he refers to ritual commandments, ceremonies by means of which we express our faith that G’d created the universe, is the only G’d, etc.
When Moses speaks of חקיו “His statutes,” he speaks of laws the reason for which has not been revealed. The commandment not to test the Lord applies to each of these categories of law.
Having dealt with the absolute demand to observe all these commandments, Moses turns to a lesser demand, i.e. to act in a manner which makes G’d’s law, and therefore the observant Jew, appear good in the eyes of man also, i.e. to occasionally do more than strict justice requires by being willing to waive something one is entitled to.
הישר והטוב [AND THOU SHALT DO] THAT WHICH IS RIGHT AND GOOD [IN THE EYES OF THE LORD] — This refers to a compromise, acting beyond the strict demands of the law.
(18) And do right and good in the eyes of the Lord. The contextual meaning of this verse is, keep God's commandments, testimonies, and laws, and prepare them to do what is good and right in God's eyes alone. And for "it may go well with you," (Deuteronomy 6:18b) it is a promise. It says, that by doing what is good in God's eyes it will be good for you, because God brings what is good to those who are good and right in their hearts. And our Rabbis in the beautiful midrash (Bava Kamma 100a) said: This refers to a compromise, acting beyond the strict demands of the law. And the intention of this is that from the beginning God said to keep God's commandments, testimonies, and laws as God has commanded them. And now, it says: even regarding what God did not command, pay attention to do what is good and right in God's eyes, because God loves goodness and righteousness. And it is important because it is impossible to mention in the Torah (what should be) everyone's conduct; with their neighbors and friends, in any business matter, and regarding ordinances of any town or country, because the Torah already mentions many of these laws, such as: "Do not gossip" (Leviticus 19:16); "You shall not take vengeance or bear a grudge" (Leviticus 19:18); "You shall not stand idly by the blood of your neighbor" (Leviticus 19:16); "You shall not insult the deaf" (Leviticus 19:14); "You shall rise before the aged" (Leviticus 19:32), etc. Once more for emphasis, generally one should do what is good and right regarding everything, including compromise, acting beyond the strict demands of the law. - (Other examples of that can be found in rabbinic literature) like what was mentioned regarding "the law of one whose field borders the field of his neighbor" (Bava Metzia 108a); and even what they said, (Regarding the depiction of the worthy prayer leader) “and his youth was becoming and he is humble and accepted by the people,” (Taanit 16a); and "he does not speak pleasantly with other people" (Ioma 86a) - until one reads about all matters of honesty and integrity.
what are the (testimonies/decrees) rituals That is to say: Why do we, intelligent human beings, accept such shackles? You shall answer that God redeemed us from the house of slavery, and He has performed all this good for us; consequently we are obliged to revere His name, having already acknowledged that He has been our Benefactor. Moreover, it will be to our benefit, and it will keep us alive — for His commandments are life to those who find them.
אשר צוה ה׳ אלוקינו אתכם, “which the Lord our G-d commanded you.” When the Torah spoke of the questions raised by the intelligent son (according to the author of the Haggadah shel Pessach who identifies him by quoting our verse), he does so seeing that this son has understood that not all the 613 commandments belong to the same category, but he has subdivided them into the three categories: ,עדות חוקים, משפטים. When it appears at first glance as if he excludes himself, because he described the laws as being addressed to אתכם “to you,” as if he were to exclude himself, he hastens to say אלוקינו “our G-d,” to prevent anyone thinking that he excludes himself. Since he is a member of the second generation and had not personally heard the Ten Commandments at Mount Sinai, he in fact is to be commended for including himself, as he could have argued that he had not said נעשה ונשמע, “we will perform the laws as soon as we know what they are.” (Exodus 24.7) This is in stark contrast to the “wicked son” in Exodus 12,26, who characterizes the laws as applying only “to you,” thereby excluding himself.
לטוב לנו כל הימים לחיותינו כהיום הזה, “to be good for us for all times as well as to have kept us alive as of this day.” This means that mitzvah-observance is good both for the body and for the soul. “Good for us for all times,” is a reference to the soul, i.e. the life in the hereafter. The term ימים is indicative of life in the hereafter, something that is prolonged, whereas life on earth is perceived as חיי שעה, “life for hours.” The words: “and to keep us alive as of this day,” are a reference to our physical existence on earth, our bodies. When the Torah describes Avraham as בא בימים in Genesis 24,1, the principal message is that Avraham had earned his hereafter, his eternal life. When David asks: “who is desirous of securing life, loving ‘days’ to see true good?” He refers to eternal life (compare Psalms 34,13). Only in those “days” will man finally experience to see the true “good.” The reason that Moses did not write כיום הזה but added the letter ה writing כהיום הזה, is a reminder of the terrestrial universe which was created by means of the letter ה, the last letter of the tetragrammaton. The reason why Moses first referred to the reward in the hereafter is that the celestial regions preceded earth in creation as a habitat.
After this Moses added: וצדקה תהיה לנו לפני ה’ אלו-הינו, “it, i.e. the performance of these commandments, will be considered a merit for us before the Lord our G’d.” The “good” promised us by the Torah will always be “in front of the Lord,” i.e. in the world of the souls. This is why Onkelos translates these words as וזכו, ”they will merit.” We may view this verse as a clear statement that there is a reward in the hereafter for performing the commandents. This then is the conclusion of the paragraph dealing with how to explain to the children of later generations why we are obligated and why it is in our interest to fulfill all these commandments.