אור החיים
Or HaChaim on Exodus 17:3
Q — At Refidim there was genuinely no water and the people were in real danger of dying of thirst — why would God bring them to such a desperate trial, the kind that 'breeds heresy'? And why does Moshe cry out against the people rather than pray for water as he did elsewhere?
A — Or HaChaim explains that God deliberately tested them to train them to lift their eyes in prayer — 'this is a great principle of faith and perfection of the soul.' For the same reason God gave the manna daily rather than monthly: the bond between Israel and their Father in Heaven must be constant and daily. God withheld the miracle until they would beseech their Creator, so that He could answer their cry.
ונראה כי ה' ניסה אותם, להדריכם לשאת עיניהם ולהתפלל לפני ה', כי זה עיקר גדול באמונה ובהשלמת הנפש. ותמצא שנתחכם ה' על הדבר, ולא נתן להם מן יום לחודש, אלא דבר יום ביומו, ואשר על כן מנע מהם הנס, עד שיתחננו למול קונם, וישמע צעקתם.