This is an interesting question. As a native speaker it appears "obvious" what it means, yet trying to explain is surprisingly difficult (at least for me!)
Why not just say 'you can't fool me' instead?
You cannot say this instead because it has a different meaning. The "you" in your version is personal, i.e. it refers to the person you are replying to.
By contrast, the "you" in "Well, you could have fooled me!" is an impersonal "you", It would be equivalent to "Well, I could have been fooled!"
Thus this is a retrospective. It is sarcastic, yes, but it also indicates acquiescence.
Sam never meant to upset you.’ ‘Well, you could have fooled me!’
This is equivalent to:
Sam never meant to upset you.’ ‘Well, when this happened I could have been fooled into believing that he did mean to upset me!’
In other words, "I accept what you say as the truth, however it seemed to me at the time that..."
Does this make sense? I don't want to over-explain.