$$
The answer to "Why?' is, as it usually is, about money.
In this case, it is about mineral resources. It is a horrible physical and societal wasteland, but it has incredible mineral reserves vital to such important playthings as iphones.
China has secured most of the mineral rights, and is building a rail line from Afghanistan into Pakistan (I think) to harvest their just reward.
Additionally, I have read there are over a million Afghan refugees living in Europe. Europe wanted them out, so making their 'homeland' more hospitable was seen as a cost-effective way of getting them to leave.
Paid for with the riches, blood, and limbs of the United States.