At the risk of sounding nutz - they are pirates because A) their country government is weak and B) their economy is terrible. It's simply the best way for them to make a living. Directly fix piracy and there will be 20 other illegal profitable rackets popping up in Somalia. You can fight the symptom, but you'll keep fighting them until you fix the root cause.
Yes, it is necessary to reduce economic, political and social differences between countries. In other words, save the planet. Since this is quite difficult in practice and also takes a long time, here's a temporary fix:
Piracy exists while it is profitable, so just increase the expenses and risks of this 'business'.
Sink pirate ships, destroy their weapons, wound their men (never kill - upkeeping of crippled is a lot more expensive than a funeral, which can also create 'martyrs'), escalate weapons and even destroy the ships they capture with their cargoes, eventually. Higher costs and risks increase the volatility of piracy results and drastically reduce their profits. I guess there are a few legal issues, though...