A Midrash included in Yalkut Eliezer quotes the verse (Psalms 13:6) "my heart shall rejoice in Thy salvation, I will sing unto the Lord because He has dealt bountifully with me" (יָגֵל לִבִּי בִּישׁוּעָתֶךָ אָשִׁירָה לַה׳ כִּי גָמַל עָלָי) and relates the words "my heart shall rejoice in Thy salvation" to the miracle of Purim and "I will sing unto the Lord" to the miracle of Hanukah.
[In other words, the Midrash uses the verse to explain why Hallel, which is not recited on Purim, is recited on Hanukah, inasmuch as the term for Hallel (ashirah) is used only in the second part of the verse.]
And our master explained that the difference between the miracle of Hanukah and the miracle of Purim is that on Purim it appeared clearly that the Holy One Blessed Be He provided for the cure before the onset of the disease in that Vashti was killed, which allowed Esther to enter the house of the king. It was through this turn of events that Haman was killed. And in the destruction of the wicked there is rejoicing, because it led to the salvation of Israel. The public reading of the Megilah is a sufficient celebration of the event, because from the recounting of the events of the story everyone recognizes that the hand of G-d miraculously guided everything, and that He alone saved their lives from the sword and kept their enemies from overcoming them. However, concerning the miracle of Hanukah, it would be possible to insinuate that it was their military prowess that saved them, because, they overcame their numerical disadvantage by risking their lives in a battle for survival. But the truth is that human salvation is in vain. The victory was achieved by the hand of G-d, for without the support of the Almighty, all hope would have been lost. It is this which obligates us to thank G-d and to praise Him forthrightly on Hanukah in order to counter those who would say that it was our hand that was victorious. In reciting Hallel, we proclaim that the salvation came from G-d.
This is the meaning of the verse "my heart shall rejoice in Thy salvation." In the miracle of Esther, my heart will rejoice in Thy salvation, because my heart can understand on its own that that famous event resulted from the salvation of G-d. But concerning the miracle of Hanukah, I must sing praises unto the Lord. There must be a special recitation of thanks and praise to G-d to publicize the miracle. For without the singing of G-d's praise, one could err, G-d forbid, and to say that it was their courage and power that achieved victory over their enemies.
Alternatively one could say that concerning the miracle of Purim only "my heart will rejoice in Thy salvation," because only my heart can rejoice in a salvation that did no more than to avoid the extermination of Israel. However, such a salvation is not enough for us to go out in song and psalm, because we remained the servants of Ahasueros, and we still remain subject to the scorn and derision of the Gentiles who rule over us and consider us slaves with whom they may do as they please. How then can we listen to psalms of songs of rejoicing? But concerning the miracle of Hanukah "I will sing unto the Lord." Concerning this salvation it is appropriate to sing aloud in public, because the victory over the enemy brought about the rule of the Hashmonaim as a result of which we gained our freedom. On Purim, therefore, the reading of the Megilah is sufficient, but on Hanukah we recite Hallel in gratitude for our liberation.
The Gemara (Shabbat 21b) asks "what is Hanukah?" Rashi interprets the question to be asking "in commemoration of which miracle did they establish it?" The Gemara explains that it was established to commemorate the miracle of the cruse of oil that burned for eight days. This is an astonishing wonder, for why would G-d perform a miracle in violation of the laws of nature just to enable some commandment to be fulfilled? Did G-d require the light of the Menorah in the Temple? All the miracles performed for our ancestors in days of old were to benefit them and to save their lives from peril or to sustain them in famine, for example the miracles at the Red Sea and in the desert. What would G-d have lost if they had not performed that commandment? For were not all the commandments given just to purify us by doing them, as Hazal say "the Torah was given only to purify mankind." But if we do not have the means by which to perform one of the commandments, we are considered to have been under duress and the Torah exempts one who is under duress from the obligation to perform a commandment. As the Sages have said, if one intended to perform a commandment, but was prevented from doing so, the Torah considers him to have performed it. If so, why did G-d overturn the natural order to allow a quantity of oil sufficient to burn for just one day to burn for eight days.?
And it appears to our master that the commandment to light the Menorah is different from the other commandments, as the Sages remarked in the Talmud (Shabbat 22b) about the verse (Leviticus 24:3) "Outside the veil of the testimony, in the tent of meeting, Aaron shall keep in order from the evening to morning before the Lord continually" (לְהַעֲלֹת נֵר תָּמִיד כא בְּאֹהֶל מוֹעֵד מִחוּץ לַפָּרֹכֶת אֲשֶׁר עַל הָעֵדֻת יַעֲרֹךְ אֹתוֹ אַהֲרֹן וּבָנָיו מֵעֶרֶב עַד בֹּקֶר לִפְנֵי ה׳):
Does He then require the light? Surely during the entire forty years that the Israelites travelled in the wilderness they traveled only by His light. But it was a testimony to mankind that the Divine Presence rests in Israel.
The Maharshah writes concerning that passage that it is impossible to say that the eternal light, like other services performed in the Temple, was a sweet savour (רֵיחַ נִיחוֹחַ לַה׳) to G-d. And see the sublime and precious comment that we have written in פרשת בהעלותך, the upshot of which is that the Menorah was not a commandment that the people performed for G-d's sake. On the contrary, G-d commanded the High Priest who served Him in the Temple to light it as a sign for the people that G-d would shine His face upon them and would allow His glory to dwell in their midst.
After Abraham our father returned from defeating Kedorlaomer and his forces, G-d said to him: "Fear not, Abram, I am thy shield, thy reward shall be exceedingly great." Rashi explains that Abraham was afraid that perhaps he had already received his full reward for the righteous deeds that he had performed, so that even if he had defeated his enemies this one time, perhaps the victory would not be permanent, because he was unworthy of all the kindnesses that G-d had performed for him, so that tomorrow or the next day his enemies would rule over him. G-d therefore promised him that his reward would be very great, and it would be everlasting. Similarly, when the spirit of G-d empowered the Hashmonaim and they achieved a victory over their enemies, they were very worried that their rule would not endure for long, because their reward from G-d was already complete after He had miraculously delivered their enemies into their hands. G-d therefore showed them a miracle through the Menorah as a sign that He would seek their peace and well-being for all time. The miraculous burning of the Menorah for eight days made it known that G-d would dwell in their midst and would raise up His countenance unto them for their good. For through the lighting of its lamps the Menorah signifies that G-d shines His face unto the Hashmonaim and would desire their well-being. And in the light of His countenance are life, favor and kindness. The frightened spirit of the Hashmonaim was thereby calmed, because they were reassured that G-d would watch over them and protect them and no evil would befall them. They therefore commemorated the miracle by prescribing the lighting of the lamp of Hanukah, because it was through the lamp that their hearts were reassured that G-d had achieved for them an enduring salvation and that their rule would survive for a long time, as, indeed, it came to pass, for the reign of the Hashmonaim lasted for many years.