In the famous give and take discussing the miracle of Purim found in Maseches Megilah 12a, quoted below with Sefaria's translation, Rabi Shimon bar Yochai tells his studets that the danger the Jews were in at the time of Purim was only a pretend danger, לפנים, in appearance , akin to their bowing to the idol which was only done לפנים, in a pretend appearance.
Soncino translates לפנים as pretend. Artscroll used the term outwardly. Adding that Hashem only made it look like they were in danger to bring them to repent. This is based on Maharsha mentione din the footnotes. Soncino too points to Maharsha.
But now the question is why celebrate this day as a holiday? While it's true that tshuva is a wonderful thing and one can argue that had we not done tshuva at that point Hashem might have allowed us to be in real danger, the fact of the matter is that at that time we were not saved from any real danger. So there was in fact no 'neis', no miraculous intervention which saved us. So why celebrate?
Even harder to understand is how we make brachos commemorating the occasion. Why Aren't all the brachos we make on reading the megila livatala, in vein? If there was no real neis, how can we make the blessing She'asa nissim?
שאלו תלמידיו את רשב"י מפני מה נתחייבו שונאיהן של ישראל שבאותו הדור כליה אמר להם אמרו אתם אמרו לו מפני שנהנו מסעודתו של אותו רשע אם כן שבשושן יהרגו שבכל העולם כולו אל יהרגו אמרו לו אמור אתה אמר להם מפני שהשתחוו לצלם The students of Rabbi Shimon bar Yoḥai asked him: For what reason were the enemies of Jewish people, a euphemism for the Jewish people themselves when exhibiting behavior that is not in their best interests, in that generation deserving of annihilation? He, Rabbi Shimon, said to them: Say the answer to your question yourselves. They said to him: It is because they partook of the feast of that wicked one, Ahasuerus, and they partook there of forbidden foods. Rabbi Shimon responded: If so, those in Shushan should have been killed as punishment, but those in the rest of the world, who did not participate in the feast, should not have been killed. They said to him: Then you say your response to our question. He said to them: It is because they prostrated before the idol that Nebuchadnezzar had made, as is recorded that the entire world bowed down before it, except for Hananiah, Mishael, and Azariah.
אמרו לו וכי משוא פנים יש בדבר אמר להם הם לא עשו אלא לפנים אף הקב"ה לא עשה עמהן אלא לפנים והיינו דכתיב (איכה ג, לג) כי לא ענה מלבו: They said to him: But if it is true that they worshipped idols and therefore deserved to be destroyed, why was a miracle performed on their behalf? Is there favoritism expressed by God here? He said to them: They did not really worship the idol, but pretended to do so only for appearance, acting as if they were carrying out the king’s command to bow before the idol. So too, the Holy One, Blessed be He, did not destroy them but did act angry with them only for appearance. He too merely pretended to desire to destroy them, as all He did was issue a threat, but in the end the decree was annulled. And this is as it is written: “For He does not afflict from His heart willingly” (Lamentations 3:33), but only for appearances’ sake.