I don't believe it would be so easy as we initially assume it would be, though. In order to fight piracy, the government of the interested country would need to invest a ton of money in vessels with military capabilities and also they would need to keep those vessels equipped with weapons and fuel for military to guard the coasts of Africa. It is not an easy task, it is actually a logistics challenge.
What I have seen corporations do to safeguard their vessels is keeping weapons on board and even attached to the vessel, so they can shoot close to the boats of the pirates and persuade them from getting close enough to get on board, though, the pirates know about this tactic and know those in the big cargo are unlikely to shoot directly at them first. So the rush for the ladders and get it.
I have read for those people who get involved in piracy, it is very tempting to do so, there have been cases of pirates becoming millionaires and being able to keep several wives after only one successful heist against an international vessel. For that kind of quality of life, they are willing to risk their integrity.
The Yemeni government should be warned that if they cannot restore order themselves, then these places will be hit accordingly. I think that’s what the US and UK did before attacking Houthi missile launchers and storage depots. Yemen is now experiencing an environmental disaster off its shores due to the sinking of the Rubymar ship, which was carrying fertilizers, as a result of a Houthi missile attack, and a fuel oil spill.