The Ohr Hachaim explains that there are some parts of Torah that a person needs to know, without which he cannot be considered a member of the Divine bond and part of the Torah. If a person does not know that he is not allowed to eat meat from an animal that became a treifa, he will eat treifa. If he does not know that he has to eat Matza on Pesach, he will not eat Matzah on Pesach.
Other Halachos of the Torah are different. For example, the rules between two litigants in Beis Din, the rules of how to sanctify the new moon, or how to bring Korbanos. Even if a person does not know these Halachos, he can still keep all of his obligations. Every Yid needs to know them, but he can still serve Hashem perfectly.
The Torah tells us here אֲשֶׁר תָּשִׂים לִׂפְנֵיהֶׁם referring to the Halachos that a person needs to know in order to live. These are for everyone, without fail. The first Halacha discussed is the one of the Jewish slave. When a person buys a Jewish slave, if he does not know the Halachos, he may think that he has bought a slave forever. The only way he can know the regulations of this purchase is if they know the rules of the purchase up front. The slave will also think that he has been sold forever, and will not know that he has only six years to serve. The Beis Din will not know that they must enforce the laws and free the slave after six years.
This law must be placed clearly in front of all of Klal Yisroel.
The Ohr Hachaim adds that a person may find this Halacha challenging to fulfill. When somebody buys a slave, he expects to own them forever. When he has to free his slave after six years, he feels that he has lost something that belongs to him. The Torah is instructing Moshe to place this Halacha in front of them. He should teach them that this Halacha is for their benefit. When the Torah was given, everyone was rich. A person only became a slave because the wheel of fortune had turned and he had become so poor that he sold his own body as a slave. The owner should know that this could have happened to him just the same, and he would want the courtesy of freedom after six years if the tables were to turn.
