Afghanistan is currently the largest opium producer in the world. It is the only significant source of wealth in the country aside from US and other foreign aid. All of this opium is going to organized crime to be sold illegally, primarily as heroin.
Meanwhile, the market is legal prescription opiates is many billions of dollars a year. Such drugs include morphine, codeine, Vicodin, and Oxycotin. These drugs are made from opium produced by licensed growers, largely in India and Turkey. There is also a large shortage of prescription opiates in the developing world, primarily among the population too poor to buy them at market rates.
Without an economic basis, there is no way for Afghanistan to stabilize, develop, and escape from poverty. And if Afghanistan does not do these things, its people will continue in lives of grinding poverty and danger, the place will continue to be ruled by warlords or religious fanatics, and the prospect of renewal as an export station for terror returns. Our military objectives in Afghanistan are beyond military powers. An army cannot provide a basis for a functioning modern society; it’s nation building or bust. And the only productive economic activity within reach is the one already being engaged in.
The solution suggests itself, and I am not the first one to notice. The International Council on Security and Development (ICOS. Formerly called the "Senlis Council") has a formal proposal to legalize the Afghan opium industry for production of legal prescription painkillers. The advisory board of ICOS includes many prominent political figures, so no one should dismiss this as a "hippy project" (though it would still be a worthy idea if advocated only by hippies).
Many of us are skeptical of the prospects for our current Afghan venture, and there is good reason. But we are in it now, and it would be much better for Afghanistan, for the US, for the region, and for the world for us to leave Afghanistan on a stronger footing than we found it. Under the Taliban, it was stable and had law and order. That is to say, it was governed, however oppressively. Under the previous period of warlord rule, it was barely governed, and that chaos is what made the emergence of the Taliban government tolerable to many. Rather than simply trying to impose our structures or values by force, we should be offering to Afghanistan the prospect for developing and taking control of its own destiny with a legitimate reason for hope. As well as growing the opium itself, at least some of the processing could be done on site, so that there are ancillary industries as well. This, too, is part of the ICOS proposal.
And this can come with strings attached. The total opium production of farmers who sell to us (for resale to global pharmaceutical firms) must go to us. We will monitor them with satellites to ensure this, but the best insurance will just be a pay them a return at least in the ballpark of what they can get on the black market (because the black market will be much less certain), and preferably much greater. We will also monitor their use of the funds to ensure they are not funding al queda or the Taliban. At the same time, we can crack down on the illegal opium in a way in which we cannot really now, because it is too vital to the country’s survival. This gives us a basis to transition from a military to a civilian mission.
One of the problems with the Bush Presidency is that he cynically debased the coin of noble goals. Bush clearly never gave a damn about improving the condition of the Afghan (or Iraqi) people, but we should. We should because we encouraged them to war with the Soviets and then abandoned them to their fate. We should because we educated, trained, and funded the mujahidin for years for our own purposes, and the Afghan people paid the price when those mujahidin struck at us. We should because we toppled a vile, but stable, government, and replaced it with instability. We also should because nothing could more effectively improve our standing in the world - particularly though not solely the Islamic world - than doing right by at least one of the countries that we have used as a pawn in our geopolitical battles. This doesn’t mean we should bite off more than we can chew, nor that we should "bear any burden". It is not an existential battle for us, so there are burdens we can legitimately refuse to bear. But a legal opium industry will cost us little and can change the whole calculus of the country.
It actually helps that the Karzai family is in the opium trade. That would be a place to start. Get Karzai to go legit. Second step is to keep him from using the government to crush competitors. Make sure the deal is open to anyone who meets specified criteria. In addition, make sure any refining operations are under separate ownership from the growing operations. That is to prevent the opium growers, people already too involved with organized crime, from being the only well-off people in the society, which would lend itself to something like feudalism.
ICOS itself is focused on using Afghanistan to supply the underserved developing world market. This is probably to avoid stepping on the toes of India and Turkey. Indeed, currently the US by law imports 80% of its opium from those two countries. The ICOS proposal is a start, but I would favor going farther, even at some costs to Turkish and Indian toes. Those two countries are far better off than Afghanistan and have fast-growing and diverse economies in which opium plays only a small role.
Update: I just wanted to add this point, which I made in comments.
At this point, US goals are pretty much put the country on such a footing that the Taliban will not be able to re-establish control and then leave. Absent Taliban resurgence, opium cultivation will continue. Karzai is not going to stop it, neither are we, and the major regional powers are mostly or entirely tied to the trade. Possibly the Taliban would if they retook power - they did before - but now they are getting a lot of the money themselves, so this is quite questionable. If you are opposed to Taliban resurgence and favor US success, you are pretty much committed to continuing large-scale opium cultivation. The question then is: legal or black market? and that's an easy choice. Conversely, if you favor Taliban victory, you still may not get eradication of opium, but you will quite likely get acid-facing of young girls.