Captain Ward here is almost certainly the pirate allegedly born in Kent, England, circa 1553 (Wikipedia). Ward terrorized the seas in the first decades of the 1600s. This song was originally published as a broadside as early as 1680 by W. Onley, London (now dated between 1689 and 1709 here). The earliest complete source in the Bodleian Libraries is closer to the 1720s. The full title was The Famous Sea-Fight between Captain Ward and the Rainbow. To the Tune of Captain Ward (suggesting the latter tune was already known, at least locally).
Most details of Ward's life come from a A True and Certaine Report of ... Captaine Ward and Danseker published by their former captive Andrew Barker in 1609. Ward worked in fisheries before signing on as a privateer. When England ended the war with Spain in 1603, letters of marque were withdrawn and many crews carried on in piracy. Around 1604, Ward was allegedly pressed into serving aboard the King's Lyon's Whelp from which he led colleagues in deserting and stealing a series of larger ships. Wards piracy quickly became a point of international contention as Venice pushed England to rein in their pirate. When Ward's royal pardon request was denied, he reluctantly settled in Tunis, garnering a corsair fleet, teaching gunnery and navigation, and living in comfort until his death in 1622.
As for the Rainbow,
The Rainbow was one of Drake's four ships that took part in the expedition in Cadiz in 1587. In a longer version of the ballad (in Child) the King refers to three captains who might have ended Ward's career earlier. They are George Clifford, Earl of Cumberland (1605), Charles Blount, Lord Mountjoy (1606) and Robert Devereux, Earl of Essex (1601). Clifford and Blount took part in the defeat of the Armada.