Like every religious festival in every religion everywhere, there is an historical element, a religious or spiritual element, and a Pagan element connected to the natural world.
The Pagan element is obvious. It's the deep mid-winter, around the winter solstice, and a time when we desperately need uplifting with a festival of lights and stodgy comfort food like latkes and doughnuts. The traditional chanukiah (nine-branched candelabra) is a similar shape to the seven-branched menorah in the Temple. It's no co-incidence that they both resemble a tree. Maybe it was meant to be the tree of life or the tree of knowledge from the Garden of Eden? Either way, here it is at the traditional Pagan Yuletide along with the Christmas tree that never appeared in the story of the Nativity.
The historical background is that while the Jews enjoyed a large amount of autonomy under the Greeks during the rule of Alexander the Great, when the Macedonian Empire split and several generations later, in the 2nd Century BCE, the Seleucid ruler Antiochus IV was more power hungry.
Meanwhile in Jerusalem there was another power struggle between the Tobiads (the assimilating Jews who embraced Greek culture, named after their leader Tobias), and the Oniads (the more othodox Jews, among them Matathias and his five sons, including Judah the Maccabee or Hammer). Both sides wanted control of the Temple. Tobias went to Syria to collude with Antiochus IV who made him the High Priest in Jerusalem, where he built a gymnasium in the Temple (apparently)!
Civil war ensued, Jew against Jew, and after two long years of battle and various stories of heroics on the part of the Oniads, Matathias and his five sons won, he rededicated the Temple to God, and Judah the Maccabee went down in [Jewish] history as one of the greatest warriors of all time.
One of the heroic stories I was told in my youth, was about a woman called Hannah who encouraged her seven sons to sacrifice their lives rather than bow down to an idol of Antiochus. Is it only me or is this story somewhat suspect? And why do we still tell it in an age where this mother would be considered heartless, brutal and abusive? For that matter, we still tell the story of Chanuka as us against the Greeks.
Moving on, the rededication of the Temple involved re-lighting the menorah which burned at all times to symbolize the eternal presence of God. So a good time to celebrate was when we light candles anyway and need a festival to break up the long winter. At some point the rabbis realized that all this celebration of a victory of war needed to be brought back under their jurisdiction. Lo and behold a miracle was added to the narrative.
The oil for the menorah had to be pure olive oil. When they started cleaning up, one cruse of pure oil was found - enough to last for one day. Either because the nearest supply of pure oil was an eight day round trip away, or because the men were impure for seven days after touching a dead body so could not produce suitable oil until the end of the eighth day, they expected to be in the dark again after the first day. Miracle of miracles, the oil lasted for the full eight days until more oil could be procured.
Now I don't mind telling the story of the miracle of the oil and concluding with, "and that, children, is why we celebrate Chanuka for eight days." It's part of the fun. Like Father Christmas on the 25th of December. (Btw, no coincidence that Chanuka falls on the 25th of the Hebrew month of Kislev. Winter solstice anyone? ) However, just as the Archbishop of Canterbury might tell the story of the Nativity but would never include Father Christmas (or even Santa Claus) coming down the chimney of the cattle barn in Bethlehem bearing gifts - because that would be silly - so too should we differentiate between history and fantasy.
There is a similar battle going on today for control of Jerusalem. We call ourselves the Left and the Right, but could easily rename ourselves as the Tobiads and the Oniads. It's the reason Israel is now facing a fourth election with no resolution. (If we reach eight elections do we get a festival?) The Ultra-Orthodox on the extreme Right see it as a fight against assimilation. The largely secular (or at least Modern Jews) aren't assimilating so much as rejecting fairy-stories told as miracles. Rejecting the fantasy world of religious despots for the real world that pays for their fantasies.
We've not quite reached a state of actual civil war, but if we do, I will blame the "miracles."