The story
From dog + -s- + body. 1818, British navy slang (dog's body), originally derogatory reference to unappetizing pease pudding (compare dog's breakfast), as if it were made of mashed dog meat. In 20th century applied to low-ranked sailors, thence menial servants in wider usage.
Etymology from Wiktionary, CC BY-SA 4.0.