The problems in Mexico run deeper than drugs. If all drugs were legalized tomorrow, or in some other way disappeared as a source of massive profits, then the cartels would just move on and co-opt some more legitimate form of business.
Heck, the cartels did it with LIMES of all things, just a couple of years ago.
The Italian mafia moved into legitimate business to protect its interests, the Lebanese mafia has been doing it in various places in the USA for years, and the cartels/Mexican mafia are involved in plenty of legitimate businesses on both sides of the border as well.
I didn't say it would be easy or cheap, but I do believe if we committed all of the resources we're currently expending on the war on drugs or building futile walls and such, on building up the Mexican infrastructure, it would be mutually beneficial, almost immediately.