the bilge is the part of a ship below the floor boards of the bottom level, just above the hull... ie the darkest and most grim part of the boat. a rat is, well, a small
annoying (and to some
people, scary) rodent. Therefore the term "bilge rat" is a
pirate insult.