The five Megillot are read, each at its time, over the course of the year. For the most part, it is easy to understand the connection between the Megilla in question and the time it is read. Eicha, naturally, is read on the 9th of Av, the date of the destruction of the Temple; Esther is read on Purim , the holiday that commemorates the events described in that Megilla. Perhaps somewhat less obviously, Shir HaShirim is read on Pesach. Pesach commemorates the exodus from Egypt, and according to the interpretations of Chazal, Shir HaShirim describes metaphorically the history of the Jewish people and its relationship to God (see Rashi, for example, on Shir HaShirim). In the early summer, on Shavuot, we read Rut, which describes events that occurred at that time of the year (during the barley harvest). In addition, Rut the Moabite takes on a life of Judaism and commitment to Torah, her own personal acceptance of the Torah, which parallels the Jewish people’s collective acceptance of Torah on Shavuot.
The reading of Kohelet on Sukkot, however, seems to be a bit out of place. Sukkot is the ultimate holiday of happiness. ושמחת בחגך… והיית אך שמח (and you shall rejoice on your holiday… and you shall be particularly happy) is a verse stated about Sukkot (Vayikra 16:15). Kohelet, on the other hand, is one of the most depressing, least encouraging works of Tanach. It focuses on the inevitability of death, the temporality of all worldly things, and the lack of ultimate value in any human endeavor. The end of the Megilla seems to find some comfort in a life of fear of God, but this seems to be only partial comfort to those who take the message of the body of the book seriously. Is Kohelet read on Sukkot only because it is the “only one left,” the last Megilla after the other four have been “taken?”
I do not have a complete answer to that question. I am not sure that I can explain the dissonance between the happiness of Sukkot and the despair of Kohelet. But I would like to point out a way in which Kohelet matches another theme of Sukkot. According to the Mishna, during Sukkot a person is to make his sukkah permanent and his house temporary (Sukkah 2:9) . The home which symbolizes permanence and solidity gets treated as something temporary and time-bound. The booth, temporary and time-bound, becomes something permanent and consistent. Similarly, when we left the established civilization of Egypt we were protected in God’s temporary dwellings in the transience of a desert existence (Vayikra 23:43). That is to say, on Sukkot we reflect on the temporality of the things we consider most permanent, by treating the temporary as permanent and vice versa. I suspect that we read Kohelet on Sukkot because we are to focus on the idea that we should not expect concrete walls and elaborate insurance policies to protect us from the temporality of life and inevitability of death. If there is ultimate meaning to be found, it is in the fear of God and the fulfillment of his commandments, for in fact the walls of our houses are really no more permanent than the walls of our Sukkot.