When trains were invented and the first railroad tracks were laid across the United States in the late 1800's, life for everyone changed dramatically.
Suddenly a person could flag down a train (using a red cloth) and hop a ride into the nearest town. This saved days of travel on foot or by wagon. People were no longer so isolated on the prairie.
There were hundreds of folk songs about this new way of life that were invented in response to this.
"Bill Grogan's Goat" was one of them:
Do you get the joke? The goat saved his own life, twice.
Once by hacking up the red shirts, saving himself from dying from intestinal blockage, and the second time by stopping the train before it hit him by "flagging" it down with those red shirts.
A version of this song is also often sung as a campfire or Boy Scout "echo" song. Every line is sung by the song leader, and then repeated by all the other singers around the campfire:
"Bill Grogan's Goat" had became such a part of American culture that at the turn of the last century almost everyone knew and recognized it.
The great movie director Alfred Hitchcock even included "Bill Grogan's Goat" in his thriller, Strangers on a Train.
In one scene, a very drunk math professor can be heard singing a piece of it in the background of the club car.