At first, maybe as early as the Stone Age, Purim was a Jewish winter festival that was probably related to the Babylonian New Year celebration and the Zoroastrian New Year’s holiday of Nowruz (and, more remotely, to the Chinese New Year). Like other West Asian people, the Jews put on funny or scary costumes and made loud noises by banging on things. Children trick-or-treated from house to house, collecting coins or candy or nuts in their baskets.
But by the time of the Maccabees, the Jews wanted their holidays to be about Jewish things, and not just the same as their neighbors. So they began to tell a story about how Queen Esther saved her people, to explain why the Jews were celebrating.
This is the story: that the Iranian king Xerxes (Ahasuerus in the Bible) wanted to marry the most beautiful girl, so he lined them all up and chose the prettiest, and that was Esther, a Jewish girl. But she didn’t tell King Xerxes she was Jewish, in case he would be angry about it. Esther had been raised by her uncle Mordecai (see how similar these names are to Ishtar and Marduk, the gods of the Babylonian New Year celebration?).
But soon after Esther became queen, King Xerxes’ bad vizier, Haman, decided to kill all the Jews in the Iranian Empire. Mordecai told Esther that she had to tell the king she was Jewish and beg him to spare her people. Esther was afraid the king would just kill her, too, but she did what her uncle said, and the king saved Mordecai, and Esther, and all of the Jews, and hanged Haman.
Mordecai became the next vizier, and he ordered the Jews to kill all of the people who had wanted to kill them, and then to keep Purim as an annual holiday forever.