A lot of ships is an Armada
We think the song dates back to the reign of Queen Elizabeth I of England, over 450 years ago. At the time, there was a rivalry between England and Spain, and the Spanish planned to invade England with an enormous fleet of ships. That is called an Armada in Spanish.
In 1588, the Spanish set off with over 130 huge ships called galleons. Each galleon needed 2,000 oak trees to build, cost the equivalent of several million pounds and needed a crew of more than 200 men. It was a huge investment for Spain.
The Armada ran into the English, who had faster ships, and then a terrible storm that scattered the galleons. Only 65 made it home. The rhyme remembers the fiasco of the Armada from the English point of view.
Sing to keep the rain away
A version very like the one we know was written about by a famous diarist called John Aubrey in 1687. He said little children used it to charm away rain so they could play outdoors. Perhaps you could try that on the next rainy day. Who knows, it may work!