[(Exodus 15:22, continued:) "They went three days in the wilderness and found no water."] Rabbi Yehoshua says: When Israel crossed through the sea, sweet water came forth for them, and from it they took into their vessels and drank. But once the water was used up, they began to complain, as it is said, "And the people murmured against Moses, etc." (Exodus 15:24). "And they came to Marah" (Exodus 15:23). They ought to have taken counsel with the greatest one among them; instead they arose and complained. Rabbi Elazar of Modi'in says: Israel was accustomed to speaking words of complaint before the Holy One, blessed be He. Immediately, "And he cried out to the LORD, and the LORD taught him a tree" (Exodus 15:25). It does not say "and He showed him" (vayar'ehu), but rather "and He taught him" (vayorehu). Rabbi Shimon ben Yochai said: He taught him [something] from the Torah, concerning which it is written, "It is a tree of life" (Proverbs 3:18). The Holy One, blessed be He, taught him, and he spoke over the water, and it became sweet.
Why the Bitter Waters of Marah Were Sweetened by Torah
Midrash Tanchuma Buber, Beshalach 18:1
[וילכו שלשת ימים במדבר ולא מצאו מים] (שמות טו כב). ר' יהושע אומר בשעה שעברו ישראל בים, יצאו להם מים מתוקים, ומהם נטלו בכליהם והיו שותים, וכיון שכלו המים היו מתרעמים, שנאמר וילונו העם על משה וגו' (שם שם כד). ויבואו מרתה (שם שם כג). היה להם להימלך בגדול שבהן, אלא עמדו ונתרעמו. ר' אלעזר המודעי אומר למודין היו ישראל לומר דברים של תרעומת לפני הקב"ה, מיד ויצעק אל ה' ויורהו ה' עץ (שם שם כה), ויראהו לא נאמר אלא ויורהו, אמר ר' שמעון בן יוחי [דבר] מן התורה שכתיב בה עץ חיים (משלי ג יח) לימדו הקב"ה, ואמר על המים ונמתקו.