God sentenced Israel to forty years of wilderness wandering because they refused to take the land of Canaan and, instead, complained.
When Israel disbelieved that they could take the land of Canaan by defeating the inhabitants who were stronger and mightier than they, GOD punished them.
10 Then all the congregation said to stone them with stones. Now the glory of the Lord appeared in the cloud upon the tabernacle of testimony before all the children of Israel.
11 Then the Lord said to Moses, “How long will these people provoke Me? How long will they not believe Me, with all the signs I performed among them? 12 I will strike them with death and destroy them, and I will make you and your father’s house into a great and more numerous nation than this one.” 13 Then Moses said to the Lord, “But the Egyptians will hear it for by Your might You brought these people up from among them, 14 and all the inhabitants of this land heard that You are the Lord among these people, who is seen plainly with the eyes, O Lord; and Your cloud stands upon them, and You go before them in a pillar of cloud by day and in a pillar of fire by night. 15 Now You would wipe out this people as one man, and the nations that heard Your name will speak, saying, 16 ‘Because the Lord was not able to bring this people into the land which He swore to give them, therefore He spread them out in the desert.’ 17 Now then, let Your strength, O Lord, be exalted in the manner You spoke, saying, 18 ‘The Lord is longsuffering and abundant in mercy and truth, taking away lawlessness, wrongdoings, and sins; but He would not cleanse the guilty by repaying the sins of the fathers on the children to the third and fourth generation.’ 19 Remit the sin of this people according to Your great mercy, as You were merciful to them from Egypt even until now.”
20 Again the Lord said to Moses, “I am merciful to them according to your word; 21 but truly, as I live, and My name lives, and all the earth shall be filled with the glory of the Lord; 22 assuredly, all the men who are seeing My glory and signs, which I did in Egypt and in this desert, and put Me to the test now these ten times, and did not heed My voice, 23 they certainly shall not see the land I swore to their fathers; but their children who are here with Me and do not know good nor evil, every inexperienced youngster, to these I shall give the land; however, all those who provoked Me shall not see it. 24 Now My servant Caleb, because he has a different spirit in him and followed Me fully, I will bring him into the land where he went, and his seed shall inherit it. 25 Now the Amalekites and the Canaanites dwell in the valley; tomorrow, turn and depart for the desert by the way of the Red Sea.”
26 Moreover the Lord spoke to Moses and Aaron, saying, 27 “How long shall I bear with this evil congregation who murmur against Me? I heard the murmuring the children of Israel make against Me. 28 Say to them, ‘As I live, says the Lord, surely in the manner you spoke in My hearing, so I will do to you: 29 your bodies shall fall in this desert, and all your census, who were numbered from twenty years old and above, as many as murmured against Me; 30 and you shall not enter the land upon which I stretched out My hand that you might settle upon it, except for Caleb the son of Jephunneh and Joshua the son of Nun; 31 but your children, whom you said would be plunder, I will bring them into the land, and they shall inherit the land from which you apostatized. 32 But your bodies shall fall in this desert; 33 however, your sons shall be shepherds in the desert forty years, and shall bear your fornication until your bodies are consumed in the desert. 34 According to the number of the days you spied out the land, forty days, for each day you shall bear your guilt one year, namely forty years, and you shall know My fierce anger. 35 I the Lord have spoken; surely I will do so to all this evil congregation gathered together against Me. In this desert they shall be utterly destroyed, and there they shall die.’” 36 Now the men Moses sent to spy out the land, and who when they returned murmured against him to the congregation by bringing an evil report of the land, 37 those very men who spoke evil words against the land died by the plague before the Lord. 38 But Joshua the son of Nun and Caleb the son of Jephunneh remained alive, of the men who went to spy out the land.Numbers 14:10-37 OSB
GOD gave the Israelites what they asked for: to die in the desert. He extended mercy to their children by not consuming them and by allowing them to enter and take the land of Canaan, but not before forty years of desert dwelling, due to the sin of the older generation.
GOD stated that this generation had tested Him ten times. The consequences of their faithlessness were severe and eternal.