It is probably of unknown, anonymous, folk origin. One of Louis Armstrong's several recordings of the song credits it to "Joe Primrose," but it is likely that Mr. Primrose was an arranger rather than an author. It seems to have also been known early on as "The Gambler's Blues," and in this form the lyrics can be traced back as far as 1899.
It is likewise hard to determine where the infirmary of the title was, although there is in fact a St. James Infirmary in San Francisco, California, and there used to be one in New Orleans, Louisiana. It would seem that the location is more likely the St. James Infirmary in New Orleans, for obvious reasons.
Like most such folksongs, there is much variation in the lyrics from one version to another. One set of lyrics goes this way:
Notable performers of this song include Cab Calloway, who can be heard singing it on the Betty Boop cartoon of Snow White; Louis Armstrong, Jack Teagarden, Billie Holliday, Janis Joplin, The Doors, The Animals, and more recently The White Stripes.
In 1981, Bob Dylan used the folk melody in Blind Willie McTell (song) about a blues singer of the same name. At the end of the lyric, we learn that the narrator is staying in the St. James hotel.