Why does Ezekiel 29 say that Egypt will be uninhabitable for 40 years?

One reason Egypt will be uninhabitable (desolate) for forty years could be the result of nuclear warfare and the effects of the Tribulation. It is very likely that the forty-year period will stretch into the millennium. The curse on Egypt will be slowly lifted during the millennium.

"And I will make the land of Egypt a desolation in the midst of desolated countries; and her cities shall be a desolation forty years among cities that are laid waste. I will scatter the Egyptians among the nations, and disperse them among the countries" (Ezekiel 29:12).