"Well I'll be damned."

How did the phrase “I’ll be damned” come to mean a sense of surprise, as used here, in post #35?

(Considering who posted it, I don’t think he meant it literally. :D)