The earliest known ancestor of Old MacDonald had a farm is A charming country life in Thomas D’Urfey’s Pills to purge melancholy (1719–20); while the verses have no resemblance to the later song, the chorus of “Here a ___, there a ___, everywhere a ___” is structurally identical.
Further eighteenth-century versions appear in other collections, and in the nineteenth century others, always with the same stock chorus but differing in other particulars, emerged in blackface minstrelsy. A version from a 1917 book of soldiers’ songs produced in London gives the first direct predecessor of the modern version, with a similar tune for the chorus and an identification of the farmer as “Old MacDougal”; it also explains the nonsensical “ee-i-ee-i-o”—Old MacDougal’s farm was “in O-hi-o-hi-o.”
This according to “Farmyard cacaphonies: Three centuries of a popular song” by Vic Gammon (Folk music journal XI/1, pp. 42-72). Above, D’Urfey, who claimed—perhaps unreliably—to have written the original song. Below, Sesame Street’s justly neglected Old MacDonald cantata.