(Numbers 29:35:) "On the eighth day you shall have a solemn assembly, etc." Let our master teach us: What is the rule concerning eating on the festival outside the sukkah? Thus our masters taught: [Rabbi Eliezer says:] A person is obligated to eat fourteen meals in the sukkah, one by day and one by night. But the Sages say: There is no fixed measure, except for the night of the first festival day [of the festival alone]. And why did the Sages permit one to be released from the sukkah on the last festival day? Rather, all seven days of the festival they were praying for dews, but on the last day they pray over the rains; therefore they are released from the sukkah, so that they may pray with a whole heart over the rains. And even so, the last festival day is counted toward the days of the festival. Why? Because thus it is written, "It shall be a solemn assembly (atseret) for you." And it would have been fitting for it to be fifty days after the festival, just as Atzeret comes fifty days after Passover. But the Holy One, blessed be He, said: It is winter, and they are unable to leave their houses and come here. Rather, while they are with Me, let them make the solemn assembly. How is this shown? From what they read on the matter: "On the eighth day a solemn assembly."
Why Shemini Atzeret Crowns Sukkot and the Prayer for Rain
Midrash Tanchuma Buber, Pinchas 13:1
ביום השמיני עצרת תהיה לכם וגו' (במדבר כט לה). ילמדנו רבינו מהו לאכול בחג חוץ לסוכה, כך שנו רבותינו [ר' אליעזר אומר] ארבע עשרה סעודות חייב אדם לאכול בסוכה, אחת ביום ואחת בלילה, וחכמים אומרים אין לדבר קצבה, חוץ מלילי יום טוב הראשון [של חג בלבד], ולמה התירו חכמים להפטר מן הסוכה ביום טוב האחרון, אלא כל שבעת ימי החג היו מתפללין לטללים, ויום האחרון מתפללין על הגשמים, לכך נפטרים מן הסוכה, כדי שיתפללו בלב שלם על הגשמים, ואעפ"כ יום טוב האחרון עולה לימות החג, למה שכך כתיב עצרת תהיה לכם, והיתה ראויה להיות אחר החג חמשים ימים, כשם שעצרת אחר הפסח חמשים ימים, אלא אמר הקב"ה חורף הוא, ואינן יכולים להניח בתיהם ולבא לכאן, אלא עד שהן אצלי יעשו עצרת, מנין ממה שקראו בענין ביום השמיני עצרת.