The structure of this prayer is of two parts. The first part is a general introduction, and is appropriate for both Chanukah and Purim. It reflects the national gratitude of the Jewish People to G-d for performing miracles for us, at key points in our history, enabling us, literally, to survive.
These miracles were both “nisim niglim,” “open miracles,” as were performed for the Jewish People on the first Chanukah, in the victory of the Chashmonaim over the Greeks and their allies, and “nisim nistarim,” “hidden miracles,” as performed by G-d for us at the time of the first Purim. The Miracle of Purim was hidden in the sense that G-d’s involvement was not apparent (on the surface, anyway), and operated in the background amid the intrigue of the Persian palace, and involved exquisite timing and apparent “coincidence.”
The text of this introduction is as follows:
“And (we thank You) for the miracles, and for the salvation, and for the mighty deeds, and for the victories, and for the battles which You performed for our forefathers in those days, at this time.”
As a prayer of gratitude, “Al HaNisim” finds its place in the section of the Shemoneh Esray reserved for expressions of gratitude to Hashem, and in a similar position in the Bircat HaMazon, where gratitude is extended beyond immediate physical sustenance, to gratitude in historical terms. In the daily version, Bircat HaMazon thanks Hashem for the inheritance of Eretz Yisrael; on Chanukah and Purim, Hashem is thanked as well for the miracles performed on our behalf on each of those occasions.