https://en.wikipedia.org/wiki/List_of_United_States_military...
It boxes Iran in, it taps on China's exposed western shoulder and borders the stans that buffer Russia's soft underbelly and it's close enough to other established air bases that can provide logistical support.
Better yet, if you do manage to capture it, it's has some of the most favorable geography for repelling invasions of any country. If America was fully established there, getting it out would be pretty much impossible.
It's not a huge shocker it was seen as a prize worthy of an expensive gamble at a time when America felt it was at the peak of its power. Anyone remember fukuyama's "the end of history"? America had a pretty severe case of hubris in the 90s/early 00s.
The war was lost a while ago, of course. It's really hard to admit defeat however, and there's always a tinge of hope it might be turned around, a disbelief that the American military could suffer defeat, so, of course it dragged on.
Anybody who has worked on a huge, vastly expensive high profile project knows that inertia can drag it on for years after it's clear to everyone that it's dead in the water.
Afghanistan would be good to have in a war with Iran, but I honestly think that the opportunity for that is gone. AFAIK Iraq has gone from being a US client state to nominally independent, and Russia’s plan to prop up the Assad regime worked out very well for them.
Strategic influence, military bases on the ground (vs. Iran) etc.
So if one would characterize complicated geo politics as gamble, I think it is fair to say the gamble was lost, considering the huge ressources spend.
"if this were the case, then the USA would have actually benefited from these wars."
I don't see where that conclusions comes from unless you fall for the same mistake you mention - adress too much competence. Also the US ruling class can loose a gamble.