At the time that song was written, the Royal Navy did not in fact rule the waves at all (we were latecomers to the colonial game relatively speaking). It was a song designed to exhort people to the goal of ruling the waves, and so (amongst other things) protecting the UK from pirate raids.
Royal Navy manpower needs vastly exceeded volunteers, so press gangs (impressment into naval service, essentially conscription) was used. If someone had some sailing experience, for example serving on a merchant vessel, they were liable to be conscripted into the navy.
Conditions on longer voyages were pretty terrible. According to everything I've read, scientific minds figured out scurvy quite some time before the same solution penetrated the skulls of the admiralty. So on long voyages there was potentially a high fatality rate of up to 50%.
My reading of this is that they needed to maintain morale. Barbary Slave raids were a credible threat everyone faced, particularly as if you were likely to be pressed (by virtue of not being useless on a ship) you were also likely to live near the coast (where there are ships). So even if you weren't particularly bothered about ruling the waves for trading or imperial reasons, preventing slave raids would be something to feel good about.
Where does this bias come from, probably, it feels much better to be battling an external enemy than to "blame the victim" as we'd say these days.
Beriberi was studied by the Japanese at a time when the theory of infections germs was developed by the Germans, and the Tokio University bought fully into this theory. There was another guy called Kanehiro Takaki who proved that it was actually caused by bad nutrition, but the Japanese army chose to ignore his findings until the Russo-Japanese war which cost so many lives due to beriberi that they were forced to adapt a better diet.
Yes, it's quite the mystery, isn't it?
Muslim slavers went as far north as Iceland. IDK why this isn't being taught, it is a part of history like any other.
(Central Europe OTOH had its own share of trauma with Ottoman slave raids. The northernmost Habsburg fortress that was built to contain them was in Těšín/Cieszyn. Look the city up on the map!)