It states (Bamidbar 11:1) בְּא ָזְנֵי רַע כְּמִת ְ אֹנְנִים הָעָם וַיְהִי אַפּוֹ וַיִּחַר 'ה וַיִּשְׁמַע 'ה, "The nation took to seeking complaints; it was bad in Hashem's ears." There are different explanations as to what they were complaining about.
Rashi writes that the Jewish nation said, "Woe to us! We have been trudging on the way for so long. We traveled for three days without rest." אַפּוֹ וַיִּחַר, Hashem was angry, and replied, "My intention was for your benefit so that you will enter Eretz Yisrael immediately." They were complaining, but they didn't realize that it was for their good.
They were punished for complaining and for not trusting in Hashem, as it states וַת ִּבְעַר הַמַּח ֲנֶה בִּקְצֵה וַת ֹּאכַל 'ה ׁאֵש בָּם, "A fire of Hashem burnt against them, and it consumed at the edge of the camp."
Just two pesukim later, the nation is complaining again. This time, they are complaining about the manna (11:4): יַא ֲכִל ֵנוּ מִי וְאֵת ֻּׁא ִיםהַק ִּש אֵת ח ִנָּם בְּמ ִצְר ַיִם נֹאכַל ֶׁראֲש ה ַדָּגָה אֶת זָכ ַרְ נוּ ,בָּשָׂר ׁ ֵ נוּנַפְש וְעַת ָּה ,ּ ׁוּמ ִיםהַש וְאֶת ה ַבְּצ ָלִים וְאֶת הֶח ָצִיר וְאֶת הָאֲבַטִּח ִים עֵינֵינוּ הַמָּן אֶל בִּלְתִּי כֹּל ין אֵ ָׁהיְבֵש, "Who will feed us meat? We remember the fish that we ate in Mitzrayim, free of charge; the cucumbers, melons, leeks, onions and garlic, but now our life is parched, there is nothing; we have nothing to anticipate but the manna." Once again, they shouldn't have complained, as the Torah elaborates on how good the manna was. Rashi writes (11:7) "See, all you who inhabit the world what my children are complaining about. The manna is excellent in so many ways!”
They were punished for complaining, as it states (11:33) 'ה וְאַף יִכָּרֵת טֶרֶם שִׁנֵּיהֶם בֵּין עוֹד ֶנּוּ ה ַבָּשָׂר מ ְאֹד ר ַבָּה מ ַכָּה בָּעָם יְהֹוָה וַיַּךְ בָעָם חָרָה, "The meat [of slav] was still between their teeth, not yet chewed, when the wrath of Hashem flared against the people. Hashem struck a very mighty blow against the nation."
The Torah is eternal, its teachings are for every generation and every Yid. We learn from this section of the Torah that we shouldn't complain. One shouldn't say, "Why did Hashem do this to me?" He must know that everything that Hashem does is for the good.