It has an unknown origin. The oldest known verse was was found in a novel titled "The Monk" written in 1796 by Matthew Lewis. It was popular during wartime.
The poem describes a newly dead corpse going through decomposition.
https://en.m.wikipedia.org/wiki/The_Hearse_Song