Devarim16:15

שִׁבְעַת יָמִים תָּחֹג לַיהוָה אֱלֹהֶיךָ בַּמָּקוֹם אֲשֶׁר־יִבְחַר יְהוָה כִּי יְבָרֶכְךָ יְהוָה אֱלֹהֶיךָ בְּכֹל תְּבוּאָתְךָ וּבְכֹל מַעֲשֵׂה יָדֶיךָ וְהָיִיתָ אַךְ שָׂמֵחַ׃

Seven days you shall keep the festival to the Eternal your Almighty in the place that the Eternal will choose, for the Eternal your Almighty will bless you in all your yield and in all the work of your hands, and you shall be altogether joyful.

Devarim 16:15

שִׁבְעַת יָמִים תָּחֹג

Devarim / Deuteronomy 16:15 · Drash

Devarim 16:15

שִׁבְעַת יָמִים תָּחֹג לַיהוָה אֱלֹהֶיךָ בַּמָּקוֹם אֲשֶׁר־יִבְחַר יְהוָה כִּי יְבָרֶכְךָ יְהוָה אֱלֹהֶיךָ בְּכֹל תְּבוּאָתְךָ וּבְכֹל מַעֲשֵׂה יָדֶיךָ וְהָיִיתָ אַךְ שָׂמֵחַ׃

Seven days you shall keep the festival to the Eternal your Almighty in the place that the Eternal will choose, for the Eternal your Almighty will bless you in all your yield and in all the work of your hands, and you shall be altogether joyful.

Drash דְּרָשׁ

Joy after judgement

It is hard to rejoice while something is still being decided: an exam, a job, health. The midrash explains why joy is said three times of Sukkot.

Midrash Aggadah: "altogether joyful" — because in this world there is no complete joy. Why is "joy" not said of Pesach, once of Shavuot and three times of Sukkot? At four times of the year the world is judged: on Pesach for grain, on Shavuot for the fruit of trees, on Rosh HaShanah all pass before Him, and on Sukkot for water. On Pesach the judgement is still ahead, on Shavuot one judgement has passed, and on Sukkot three have passed, hence three joys.

How Midrash Aggadah explain it

Midrash Aggadah And you shall be altogether joyful

What is "only" (אַךְ)? That in this world there is no complete joy: His children grieve Him at the table.

Midrash Aggadah

Why is "joy" not said of Pesach, and of Shavuot one joy is written, as it is written: "And you shall rejoice before the Eternal your Almighty" (Devarim / Deuteronomy 16:11), and of the festival of Booths (Sukkot) three joys are written, as it is written: "And you shall rejoice in your festival" (Devarim / Deuteronomy 16:14), "and you shall be altogether joyful"?

Because we learned: at four times of the year the world is judged. On Pesach for grain, on Shavuot for the fruit of the tree, and on Rosh HaShanah all who come into the world pass before Him like sheep, as it is said: "He who fashions their hearts alike" and so on (Tehillim / Psalms 33:15). And on the festival of Booths they are judged for water.

The time of Pesach is a lack, there is still work to do, so "joy" is not written of it. But on Shavuot one judgement has passed, so one joy is said of it. And on the festival of Booths three judgements have already passed — Pesach, Shavuot and Rosh HaShanah — so three joys are said of it.

Takeaway

"At four times of the year the world is judged" is from the Mishnah (Rosh HaShanah 1:2).
"His children grieve Him at the table": a father's joy is not full while his children are not all good. The midrash reads אַךְ as a limit: there will be joy, but not complete.
Rosh on this page explains the three joys by the harvest: on Sukkot everything is gathered. Midrash Aggadah explains them by the judgements: on Sukkot three judgements are behind.