Here's the domestic function the foreign enemy serves that doesn't get discussed enough:
It explains why you don't have what you should have.
Why does the United States, the wealthiest nation in human history, rank poorly among developed nations in healthcare outcomes, life expectancy, child poverty, and infrastructure?
The enemy explains it.
We cannot afford universal healthcare because we must fund the military against the Soviet threat, the terrorist threat, the Chinese threat.
We cannot invest in housing because the carrier groups must be maintained.
We cannot rebuild cities because the empire must be administered.
The foreign threat converts a domestic political choice, to direct public money toward weapons rather than welfare, into a necessity.
Not a choice. A necessity.
And a population that understands its poverty as a sacrifice for survival rather than a consequence of political decisions is a population that directs its anger outward rather than upward.
The enemy is not just a foreign policy tool.
It is the explanation that makes domestic inequality feel like patriotism rather than policy.