Immediately, the text itself likens the two men when, at the climax of the megillah, Mordechai is dressed in the clothes and given the honors, that Haman believed would be designated for him. Similarly, both men orchestrate their plots from behind the scenes, and the Midrash tells us that they were mistaken for one another by Haman’s daughter during the climactic farse. To understand why Haman and Mordechai are equated, and we are told to not know the difference between the curse of Haman and the blessing of Mordechai, we have to examine their roles in the narrative. When we first meet both people, they are somewhat in hiding (a common theme of the megillah). Mordechai is hiding Esther from the king, and Haman is an inconsequential chamberlain with another name. The Jewish people too have become acculturated to the point of attending a party celebrating their own defeat. They are hiding amongst the gentiles. Mordechai, in the Midrash, expresses opposition to the party, to this acculturation, without success. The Jewish people are undifferentiated to the point of not even being mentioned in the text, at this point. Haman, principally wants to destroy the Jewish people and so, he needs them to be differentiated to the king. Unfortunately, the king doesn’t want to acknowledge their existence, preferring a homogeneous empire, and so Haman has to convince the king that an anonymous people is actually destroying his empire. The anonymity here gives the king plausible deniability, but the idea of a distinct nation is still formulated. Even the way Haman selects the day to kill the Jews is by a lottery which selects a single option from a homogeneous collective.
Meanwhile, Mordechai sends Esther (Hebrew for hidden) on an undercover mission in the palace. In this way, the king doesn’t know her national identity just like he “doesn’t know” which nation his viceroy is about to destroy. This equates Esther to the Jewish people, who are both hidden among those who wish to destroy them. In the end, the farce breaks, and Esther reveals herself and the Jewish people is revealed as the hidden nation. The Jewish people are finally differentiated both by Haman and by Mordechai. And Haman now loses his cloak of ambiguity and must be punished, and Mordechai is rewarded as a representative of his people. Thus, the very mechanism that curses Haman blesses Mordechai.
On a deeper level, we are told that Purim is the day when the Jews finally accepted the Torah in full. Just as the plot brought Esther out of hiding, it also brought the Jews out of assimilation and made them self identity, for the first time voluntarily, as a nation. In this way, they chose to accept the Torah of their own accord, and Gd sent both a leader to bring them to this self selection and an antagonist, who both served the same role. It’s at the point when Haman builds his gallows when the “King’s Sleep” is awakened (the King homiletically referring to Gd) and He “recognizes” the good of his people.
Good and evil are both creations of Gd and serve the same role towards the same ends. It is evil that drives us to recognize ourselves as distinct by its contrast and it is good that calls us to a separate mission.