It refers to a dead Union soldier of the same (rather common) name, as Mark Steyn notes:
At the time, Dr Samuel Howe was working with the Sanitary Commission of the Department of War, and one fall day he and Mrs Howe were taken to a camp a few miles from Washington for a review of General McClellans Army of the Potomac. That day, for the first time in her life, Julia Ward Howe heard soldiers singing:
John Browns body lies a-mouldring in the grave
John Browns body lies a-mouldring in the grave
Ah, yes. The famous song about the famous abolitionist hanged in 1859 in Charlestown, Virginia before a crowd including Robert E Lee, Stonewall Jackson and John Wilkes Booth.
Well, no, not exactly. By a strange quirk of history, wrote Irwin Silber, the great musicologist of Civil War folk songs, John Browns Body was not composed originally about the fiery Abolitionist at all. The namesake for the song, it turns out, was Sergeant John Brown, a Scotsman, a member of the Second Batallion, Boston Light Infantry Volunteer Militia.
Thank you very much for that correction.