I can just see trying to HIT an outboard on a bouncing skiff from a moving vessel with a Barrett, though in most cases you probably wouldn't have to. Half a dozen rounds into or around the boat would probably change their minds.
Some countries take a dim view of an armed vessel of any kind coming into their waters, just as some cities/governments don't want you "carrying" onto their property. As merchant vessels are all about TRADE, their owners don't want to be carrying anything that might interfere with doing business. It's not like they can leave their ordinance at the sea buoy. Also should the weapons get into the wrong hands they could be a danger to the ship's own crew.
Then there's the bottom line, cost; in most cases those weapons would just be an expense, what with the cost, maintenance, training, and liability. As modern-day pirates are mostly about ransom, it's a lot cheaper to simply carry insurance.
Each country controls it's own waters and makes it's own laws regarding same. There is the "law of the sea" and the "right of innocent passage", however once you're armed, you're no longer "innocent".
Just like carrying your 9mm into the Federal building. If it's found, it's suddenly more trouble than it's worth.
All those are just possible reasons. I can't quote any specific laws.