I've had a wonderful time; this wasn't it.
The joke works on the cancellation of a previously created implicature.
The first clause,
- I've had a wonderful time;
implies that the speaker (the "I") has just had a wonderful time -- that the most recent event was that wonderful time. (But this is not an entailment, and so could be explicitly cancelled, and if cancelled, it is usually cancelled almost immediately in the next clause or sentence by native English speakers.)
The next clause,
cancels that previous implicature. Thus, the "joke".
I've noticed that many EFL speakers can't get the handle on this sort of creation and canceling of implicatures. (Aside: Especially the ones who think they know English grammar better than the native speakers, and they argue and argue, not understanding that what they are saying ain't quite what they think it is.)
EDITED to add more info:
One of the main differences between the present-perfect construction and the past-perfect is that the present-perfect explicitly includes the present time-sphere. Both types of perfect construction include the past time-sphere.
In the OP's example "I've had a wonderful time; this wasn't it", the verb construction of the first main clause has not changed -- it is still a present-perfect construction, which is used to talk about the past but with the understanding that the present is also important.
If the present wasn't to be included (present == this current social event), then the speaker would normally use the past-perfect ("I had had a wonderful time") which would explicitly omit that current/recent social event, but that would sound weird for this social situation, where it is assumed that a guest is thanking the host for a wonderful time at the host's event. And that assumption of "thanks" is needed for the joke to work.
If a guest wanted to thank the host, then the simple past would often work, "I had a wonderful time", as it could refer to the very recent past which could refer to the just concluded social event. But then the joke probably wouldn't work as well,
- I had a wonderful time; this wasn't it."
For the original joke with the present-perfect is explicitly including the present time-sphere, which strongly pulls in the implicature that the speaker is talking about the current social event as being that "a wonderful time".
The present-perfect has various uses, and one of them is to talk about a past situation that is very close to "now". Often, that situation is the present situation or a very recent situation. The joke relies on that common usage.