"The Grand old Duke of York" is a well-known English nursery rhyme concerning the exploits of an not-specifically-identified duke of York. Wikipedia, citing the Opies and other books, gives a summary of the state of knowledge concerning which duke and which historical event are being referred to (TL;DR: we don't know), but I'm more interested in the process by which a historical event (whichever one it may be) became a popular nursery rhyme.
One can assume that the people singing this rhyme to their children were likely not members of the nobility who would've actually known any dukes. Since we're talking about centuries ago, before mass media or even mass literacy was a thing, how would ordinary people even have known about a duke marching an army up and down a hill? Could it have been a story brought home by returning soldiers who never understood why they were ordered to march, or by people who saw armies marching from afar? Even if so, why would they turn such events into a song for their children?
Have there been any folklorological studies of how such events became children's songs?