When a man is visited by suffering, he should reflect on the allegory of the father of a small son who disguises himself so as to frighten his son. If the son understands and sees that it is really his father, he cries out to him, “Father!” The father, in turn, responds tenderly, removing his strange garments and revealing his true identity to his son. This is the son’s pain nullified. So it is with man. When he experiences any form of grief, heaven forbid, if he understands that nothing exists except for H'shem, and that it is He Who is causing him this pain to see if he will have the wisdom to call out to Him, then the pain will be banished. But when man is not wise enough to know that everything comes from Him, and looks to medicines and other physical methods to be saved from this path, then, heaven forbid, he will remain as he was. Baal Shem Tov, Orah le-Hayyimchiburim.sefaria.org.il
We understand from this Midrash that praising H'shem saved the Jewish nation when tefillos couldn't. The sea split before Bnei Yisrael because Moshe praised H'shem for the miracles that will be. Noam Elimelech (Likutei Shoshanah, ה"ד ומעל חלש תודפ) writes: "H'shem always prepares the cure before He smites (הכמל האופר םידקמ). What is the cure which H'shem prepares? It is to praise H'shem's great name... As we say in davening: תואפר ארוב, H'shem prepares the cure, תוליהת ארונ, with our praises." Because when we praise Hashem for the upcoming salvations, we will merit experiencing them.
Torah Wellsprind/ Shabbat Hagadol