As another commenter pointed out, the “40 years” was more figurative, likely meaning something more like “a generation.”
The reason being, I’ve heard, as they fled Egypt, they were fleeing slavery, the only form of life they had known. For their people to settle successfully, they needed to wander for “40 years/a generation” so that they could know what it was like to live as a free people.
As another commenter pointed out, the “40 years” was more figurative, likely meaning something more like “a generation.”
The reason being, I’ve heard, as they fled Egypt, they were fleeing slavery, the only form of life they had known. For their people to settle successfully, they needed to wander for “40 years/a generation” so that they could know what it was like to live as a free people.
40 seems to have a symbolic meaning: https://www.yeshiva.co/midrash/48664