There is an age old question of how the Jews in the desert could continuously complain about their situations; after all, they knew that Hashem was more than willing to produce miracles for their benefit! To find the answer to this question, we must examine the beginning and end of this week’s Parsha. At the very beginning, Hashem decides to take the Jews to Israel in a roundabout way. The reason He gives for this is to prevent war with the Pelishtim, lest the Jews become afraid and try to return to Egypt. However, less then two weeks later the Jews are attacked by Amalek, and not a single person wanted to return to Egypt. How could Hashem say they would be afraid of war if it soon became apparent that they were not?
Rabbenu Bachya, quoting Rabbenu Chananel, answers that the reason for going the long way in the desert really had nothing to do with wars; this was merely an excuse. Hashem’s real reason was that he wanted the opportunity to perform miracles on a large scale for the Jews in order to create a recognition of His power. Had the Jews gone directly to face the Pelishtim, it would only have taken one small miracle to destroy them, and they would have gone on to conquer the land of Israel. However, Hashem decided to spend two years (which was later increased to forty) teaching the Jews about Him by doing many miracles in the desert. One example of this was the manna. Most travelers carry at least a week’s supply of food with them when they travel, but the Jews were required to rely on Hashem to give them food every day. Hashem’s teaching method took a long time and needed much reinforcement. The Jews were not able to grasp all the fundamentals until after forty years of teaching.
Now we can return to our original question. The Jews were slow learners and did not grasp right away that Hashem would give them whatever they needed. Therefore, when things got tough, they did not realize that Hashem would help them, so they resorted to complaining.