The context clues here point to a late 19th century music hall origin, but the jargon suggests at least some familiarity with nautical life. Kenneth Goldstein's liner notes for Paul Clayton's Foc'sle Songs and Shanties album (1959) read:

This delightful British foc'sle ditty has been collected only rarely from tradition. More than likely it was first popularized in British music halls, and taken from there to the foc'sle by one of the many sailors who frequented the music halls on their layover between ocean trips. Mrs. Clifford Beckett, who supplied the only text I have found in print, suggests that the 'good ship Ragamuffin' refers to the old Bellerophon.

Beckett published a short book of eight Shanties and Forebitters in 1914. The HMS Bellerophon, colloquially called the Billy Ruffian, was a Royal Navy ship from 1786.