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.
Strike up, you lusty gallants, with musick and sound of drum,
For we have descryed a rover, upon the sea is come;
His name is Captain Ward, right well it doth appear,
There has not been such a rover found out this thousand year.
For he hath sent unto our king, the sixth of January,
Desiring that he might come in, with all his company:
`And if your king will let me come till I my tale have told,
I will bestow for my ransome full thirty tun of gold.'
`O nay! O nay!' then said our king, `O nay! this may not be,
To yield to such a rover my self will not agree;
He hath deceivd the French-man, likewise the King of Spain,
And how can he be true to me that hath been false to twain?'
With that our king provided a ship of worthy fame,
Rainbow she is called, if you would know her name;
Now the gallant Rainbow she rowes upon the sea,
Five hundred gallant seamen to bear her company.
The Dutch-man and the Spaniard she made them for to flye,
Also the bonny French-man, as she met him on the sea:
When as this gallant Rainbow did come where Ward did lye,
`Where is the captain of this ship?' this gallant Rainbow did cry.
`O that am I,' says Captain Ward, 'There's no man bids me lye,
And if thou art the king's fair ship, thou art welcome unto me:'
`I'le tell thee what,' says Rainbow, 'our king is in great grief
That thou shouldst lye upon the sea and play the arrant thief,
`And will not let our merchants ships pass as they did before;
Such tydings to our king is come, which grieves his heart full sore.'
With that this gallant Rainbow she shot, out of her pride,
Full fifty gallant brass pieces, charged on every side.
And yet these gallant shooters prevailed not a pin,
Though they were brass on the out-side, brave Ward was steel within;
`Shoot on, shoot on,' says Captain Ward, 'your sport well pleaseth me,
And he that first gives over shall yield unto the sea.
`I never wrongd an English ship, but Turk and King of Spain,
For and the jovial Dutch-man as I met on the main.
If I had known your king but one two years before,
I would have savd brave Essex life, whose death did grieve me sore.
`Go tell the King of England, go tell him thus from me,
If he reign king of all the land, I will reign king at sea.'
With that the gallant Rainbow shot, and shot, and shot in vain,
And left the rover's company, and returnd home again.
`Our royal king of England, your ship's returned again,
For Ward's ship is so strong it never will be tane:'
`O everlasting!' says our king, `I have lost jewels three,
Which would have gone unto the seas and brought proud Ward to me.
`The first was Lord Clifford, Earl of Cumberland;
The second was the lord Mountjoy, as you shall understand;
The third was brave Essex, from field would never flee;
Which would a gone unto the seas and brought proud Ward to me.'