(I mean this as an honest question, i don't know that much of the geopolitics of the region)
"Afghanistan may be sitting on one of the richest troves of minerals in the world, valued at nearly $1 trillion, scientists say."
https://www.nbcnews.com/science/science-news/rare-earth-afgh...
The Chinese will ask no questions, will do the work, and wont bother the Taliban with annoying issues like freedom and democracy. A perfect match.
Are you aware that one of the most cliché jokes told outside of the U.S. is some variation of "when an American says democracy, everyone ducks for cover"?
Having said that, it didn't work at all. China patiently used those 20 years to develop its economy and infrastructure, locked down Xinjiang against subversion, set up Belt and Road, and gained strategic tempo in the South China Sea and the Taiwan Strait while the US got much too carried away in Central Asia.
To humiliate America
Other than the Khybar Pass, Afghanistan is a piece of land of very little value, and only 38 million of very proud, and militant people.