As far as I can see, we have three basic choices.
1. Try to establish a democratic government, which will collapse the moment the US withdraws and leaves the Taliban in control and unrestrained.
2. Try to establish a puppet dictatorship, which is sufficiently ruthless coud theoretically resist the taliban if given enough US support in terms of arms and such. The Taliban would eventually incorporate themselves into the dictatorship itself, but at least then they would be on a leash. This is probably the optimal solution. Yes, in a few generations people will probably be going on about how badly America behaved and laying all the crimes comitted by the regime on the door of the Whitehouse, but strawberry float those hippies; they don't understand how the world works.
3. Just stay there indefinitely. This is probably the worst option and would only be made if you were smart enough not to attempt option 1 but were too morally squeamish to attempt option 2.
Are any of these options better than not invading at all in the first place? Lol, no.