Rats live down at the bottom of a ship, so when a ship is taking on water, the rats seek a higher, dry place. So when a ship is sinking, one sees the rats coming up. And they are the first to know that water is collecting in the holds.
Along the lines of what @zenvelo says, pirates would insult you by calling you a bilge rat.
The bilge being the foulest/darkest part of a ship located beneath the floorboards on the lowest deck.