The earliest writen versions of the song were about 1926 and I suggest that people were singing it some years before that. The Spanish flu epidemic had occurred in 1918-1920 and a lot of people died it is probably inspired by the loss of family during that epidemic.