כִּ֣י ׀ אַרְבָּעִ֣ים שָׁנָ֗ה הָלְכ֣וּ בְנֵֽי־יִשְׂרָאֵל֮ בַּמִּדְבָּר֒ עַד־תֹּ֨ם כָּל־הַגּ֜וֹי אַנְשֵׁ֤י הַמִּלְחָמָה֙ הַיֹּצְאִ֣ים מִמִּצְרַ֔יִם אֲשֶׁ֥ר לֹֽא־שָׁמְע֖וּ בְּק֣וֹל יְהוָ֑ה אֲשֶׁ֨ר נִשְׁבַּ֤ע יְהוָה֙ לָהֶ֔ם לְבִלְתִּ֞י הַרְאוֹתָ֣ם אֶת־הָאָ֗רֶץ אֲשֶׁר֩ נִשְׁבַּ֨ע יְהוָ֤ה לַֽאֲבוֹתָם֙ לָ֣תֶת לָ֔נוּ אֶ֛רֶץ זָבַ֥ת חָלָ֖ב וּדְבָֽשׁ׃
For the children of Israel walked forty years in the wilderness, till all the nation, even the men of war that came forth out of Egypt, were consumed, because they hearkened not unto the voice of the LORD; unto whom the LORD swore that He would not let them see the land which the LORD swore unto their fathers that He would give us, a land flowing with milk and honey.
Zohar
Rav Huna said, Come and behold, "For the children of Yisrael walked forty years in the wilderness because they obeyed not the voice of Hashem" (Joshua 5:6). In this verse, it is the same. Rabbi Yosef said, Everything that was said is the same, but for one thing. At the end of forty years, when the troubles pass away and the wicked are exterminated, the dead, the dwellers of the dust, shall live. Why? Because it is written, "affliction shall not rise up the second time" (Nehemiah 1:9). They had their fill with what they had. After the resurrection of the dead, the world will be settled, as it is written, "on that day Hashem shall be One and His Name One" (Zecharyah 14:9).