Midrash Rabbah

Kohelet Rabbah 11.8

1

כִּי אִם שָׁנִים הַרְבֵּה, יִשְׂמַח בְּשִׂמְחַת הַתּוֹרָה, וְיִזְכֹּר אֶת יְמֵי חַיֵּי הַחשֶׁךְ, אֵלּוּ יְמֵי הָרָעָה. כִּי הַרְבֵּה יִהְיוּ, תּוֹרָה שֶׁאָדָם לָמֵד בָּעוֹלָם הַזֶּה, הֶבֶל הִיא לִפְנֵי תּוֹרָתוֹ שֶׁל מָשִׁיחַ.

“For if a man lives many years, let him rejoice in all of them, and remember the days of darkness, as they will be many. Everything that is coming is vanity” (Ecclesiastes 11:8). “For if [a man lives] many years,” “let him rejoice” in the joy of the Torah; “and remember the days of darkness” – these are the bad days, “as they will be many.” The Torah that a person studies in this world is vanity relative to the Torah of the Messiah.