There is a Midrash that says a king returned victoriously from war and hung his weapons on the wall, which is apparently related to Sukkos. Where is this Midrash?
. אֵלּוּ וְאֵלּוּ נִכְנָסִין לִפְנֵי הַמֶּלֶךְ לְדִין, וְאֵין אָנוּ יוֹדְעִין מִי הָיָה מְנַצֵּחַ. מָשָׁל לְמָה הַדָּבָר דּוֹמֶה. לִשְׁנֵי בְּנֵי אָדָם שֶׁנִּכְנְסוּ לְדִין לִפְנֵי הַמֶּלֶךְ, וְלֹא הָיָה יוֹדֵעַ אָדָם מַה בֵּינֵיהֶם אֶלָּא הַמֶּלֶךְ בִּלְבָד. דָּן הַמֶּלֶךְ אוֹתָן, וְלֹא הָיוּ יוֹדְעִין הַבְּרִיּוֹת מִי נוֹצֵחַ לַחֲבֵרוֹ. אָמַר הַמֶּלֶךְ, כָּל מִי שֶׁהוּא יוֹצֵא וּבְיָדוֹ אֲגִין, הֲווּ יוֹדְעִין שֶׁהוּא נָצַח. כָּךְ יִשְׂרָאֵל וְאֻמּוֹת הָעוֹלָם נִכְנָסִין לְדִין בְּיוֹם הַכִּפּוּרִים, וְאֵין הַבְּרִיּוֹת יוֹדְעִין מִי נָצַח. אָמַר הַקָּדוֹשׁ בָּרוּךְ הוּא, טְלוּ לוּלְבֵיכֶם בְּיֶדְכֶם, שֶׁיֵּדְעוּ הַכֹּל שֶׁאַתֶּם זְכִיתֶם בַּדִּין.
The former and the latter come [for a verdict], but we do not know who has prevailed. To what is the matter comparable? To two humans who came before the king for a verdict. Now no one except the king himself knew what [the issue] was between them. The king judged them, but the people did not know who had prevailed against his companion. [However], the king said, “You should know that whoever leaves with a lance in his hand has prevailed.” So Israel and the peoples of the world come for a verdict on the Day of Atonement, and the people do not know who is victorious. The Holy One, blessed be He, said, “Take your lulavim in your hand, so that everyone may know that you have won in the judgment.”
אָמַר רַבִּי אָבִין מָשָׁל לִשְׁנַיִם שֶׁנִּכְנְסוּ אֵצֶל הַדַּיָּן וְלֵית אֲנַן יָדְעִין מַאן הוּא נוֹצֵחַ, אֶלָּא מַאן דְּנָסַב בָּאיָין בִּידֵיהּ, אֲנַן יָדְעִין דְּהוּא נָצוֹחַיָיא, כָּךְ יִשְׂרָאֵל וְאֻמּוֹת הָעוֹלָם בָּאִין וּמְקַטְרְגִים לִפְנֵי הַקָּדוֹשׁ בָּרוּךְ הוּא בְּרֹאשׁ הַשָּׁנָה וְלֵית אֲנַן יָדְעִין מַאן נָצַח, אֶלָּא בַּמֶּה שֶׁיִּשְׂרָאֵל יוֹצְאִין מִלִּפְנֵי הַקָּדוֹשׁ בָּרוּךְ הוּא וְלוּלָבֵיהֶן וְאֶתְרוֹגֵיהֶן בְּיָדָן, אָנוּ יוֹדְעִין דְיִשְׂרָאֵל אִינוּן נָצוֹחַיָּא, לְפִיכָךְ משֶׁה מַזְהִיר לְיִשְׂרָאֵל וְאוֹמֵר לָהֶם: וּלְקַחְתֶּם לָכֶם בַּיּוֹם הָרִאשׁוֹן.
Rabbi Avin said, "[There is a relevant] parable about two that went into a judge and we do not know who was victorious. Rather we know that the one that [comes out] carrying a palm branch is the winner. So [too] Israel and the nations of the world come and prosecute [each other] before the Holy One, blessed be He, on Rosh Hashanah and we do not know who won. Rather when we see that Israel is coming out from in front of the Holy One, blessed be He, with their lulavs and citrons in their hands, we know that Israel are the winners (and that creates a need to offer an offering of joy, as well as the holiday offering). Hence, Moshe warns Israel and says to them (Leviticus 23:40), 'And you shall take for yourselves.'"
Kohelet Rabbah, a collection of midrashim on the book of Ecclesiastes. The specific passage is Kohelet Rabbah 1:5 and it reads:
"Rabbi Levi said: A parable: To what is this matter [i.e. Sukkos] similar? To a king who had a war with his enemies and was victorious. When he returned to his palace, he said: Let all who wish to see me come and see me. And when they came to see him, he took out all the arms and weapons that he had used in the war and hung them up. Similarly, when the Holy One, blessed be He, gave victory to Israel over their enemies and they returned to their homes in peace, they said: Let us go and behold the king in his beauty. And what did they see? They saw the sukkah, as it is said: "Go forth and look, O daughters of Zion, upon King Solomon, upon the crown wherewith his mother hath crowned him in the day of his espousals, and in the day of the gladness of his heart" (Song of Songs 3:11). The crown referred to here is the sukkah."
In this passage, the sukkah is seen as a symbol of victory and peace, just as the weapons were a symbol of victory for the king in the parable. The idea is that the sukkah represents a time of rest and peace after a time of war and struggle, and it is a reminder of the protection and shelter that God provided for the Israelites during their journey in the wilderness.