Two Bible scholars write: The final step for the creation of the Megillah was connecting the combined story to the (preexisting) Festival of Purim. The name Purim is based on the Akkadian word for “lots” (pūrū). Many scholars believe that the holiday originated as a Persian new- year celebration, which included the casting lots as one of the rituals.
The Megillah, however, uses these festival lots in a different way, imagining the lots as having been cast by Haman to determine the most auspicious time to kill the Jews. It was at this stage that verses like 3:7, which explain how the 13th of Adar was chosen as the fateful day, and much of chs. 8-9 were written.
This recast the story of Mordechai and Esther vs. Haman into a story that undergirds the festival calendar. It justified the Persian Jewish community’s celebration of a new-year festival by turning it into a Jewish festival. Thus the same process that we can see having occurred for Pesach and Sukkot in the Torah, and Shavuot in Second Temple and Rabbinic literature, occurred for Purim as well.