Eric Zorn of the Chicago Tribune wrote this column about some of the euphemisms we use. One thing he points out is that "rats!" is so disconnected from its original that it's hard to know where it came from. My first thought was to check with Quinion, but it's not there. Does anyone know what that original connection was?
Other than Etymology Online (under the entry rat) which says American in origin and gives a first citation of 1886. I can find no discussion of its origin online. People do wonder. It's probably from the word rat, the rodent, and it is mildly pejorative, cf. [i[crap[/i] as an interjection.