Jokes often arise involuntarily, like dreams, and tend to be swiftly forgotten. From these similarities Freud inferred that jokes and dreams share a common origin in the unconscious. Both are essentially means of outwitting our inner 'censor'.
Jim Holt