Bathrooms in trains used to empty right onto the tracks. This worked well in the middle of cornfields and traveling at 50 MPH. It is a major problem when the train is sitting still in a station.
There is a story (probably apocryphal) that the first verse was written by Supreme Court justice William O. Douglas and Yale law professor Thurman Arnold. They were inspired by a sign in the toilet of a train. They set it to the tune by Dvorak and immediately taught it to all the passengers. Every classical violin student knows, and probably hates, the dotted rhythms.
As with most of the songs in this section, I learned it from Oscar Brand.