Iran has a real army, and America is a giant pussy, so they won't fuck with Iran. They want to fuck with Iran, though, because the Saudis spend lots of money on America's behalf.
If you look at a map, you can see Afghanistan in on the right of Iran, and Iraq on the left. Encirclement is always a good strategic choice. It's a convenient place to stage operatives from, at least. You can do things like 'encourage' some terrorists to pay them a visit. With bases on both sides, you can try to bluff Iran. "I'ma find my balls! Any day now!"
The actual 9/11 terrorists - assuming the FBI didn't just lie outright - were Saudi. The "war" in the middle East never had anything to do with terrorism, except American terrorism of Iran. Imagine American terrorists blew up something in Russia, and Russia responded by staffing bases in North Korea and Mongolia. Be quite the WTF moment, eh? Indians blow up something in China, so CCP invades Pakistan...
You would think Afghanistan was a Red Empire action, but it rapidly became Blue Empire, with Foggy Bottom apparently calling all the shots. Martial law via lawyer rules didn't work out. Everyone was shocked, shocked. Red Empire was still paying for it, though, just in case you weren't sure if the Republicans were the Democrat's fuck holes.
It is possible they withdrew now just to piss off Trump.
Wait I have a plausible theory: they had to pay off certain Red Empire operatives to pull off the election fraud, and ending the buggering in Afghanistan was part of the deal. If the "war" there was in any way bad for Blue Empire, it would have been ended under Obama II at the latest.