Parshas Vayeilech contains two mitzvos: 1.) Hakhel—Gathering the entire people in Jerusalem after the Sabbatical year to hear the King read from the Torah (31:10-13). And, 2.) The mitzvah of writing a Torah scroll (31:19).
What is the significance of the fact that these are the last two mitzvos recorded in the Torah, both transmitted by Moshe on the day of his passing?
As long as the Jewish people were in the desert, memories of the experience at Sinai remained fresh. Even those members of the next generation who had not seen the giving of the Torah with their eyes, had nevertheless grown up in a spiritual oasis where the effects of Sinai were still palpable.
But at this junction in time, the Jewish people were leaving that oasis and embarking on the formidable challenge of living a life dominated by earning one’s physical needs—and this was to be without the leadership of Moshe. To help overcome these hurdles, the Jewish people were given two mitzvos whose purpose was to enable them to recreate the experience of Sinai in their new setting.
Thus Rambam writes that, at a Hakhel gathering: “They must prepare their hearts and alert their ears to listen with dread and awe and with trembling joy, like the day it was given on Sinai...as though the Torah was being commanded to him now, and he was hearing it from the mouth of the Almighty, for the king is an agent to make the words of God heard” (Laws of Festival Offerings 3:6).
However, this only recreates the experience of being commanded by God as a nation to observe the mitzvos. In order to re-enact the experience of being given the Torah personally by God to study, a further mitzvah was given—to write a Torah scroll. For when: “a person writes one with his own hand, it is as if he received it from Mount Sinai” (Rambam).
(Based on Likutei Sichos vol. 34, p. 189ff.)