I have to admit that I am a devout fan of the dad joke: A turn of phrase characterized as being amusing but corny. So good they are bad, dad jokes crop up at all kinds of family gatherings and holidays. How did we get so lucky to have a plethora of knock-knock-who's-there and a-guy-walks-into-a-bar? We take it so much for granted that different people find different things funny, but why are humans funny at all? How and why did we evolve humor in the first place? Scientists have been trying to determine what makes something "funny" as a first step toward hypothesizing why we evolved mirth and what neurological purpose it serves. Was it to repair incongruities in our thinking, or because laughter provides relief from nervous tension, or perhaps because we take pleasure in our superiority over others? These are three of the main theories of humor: Incongruity, relief and superiority.
Computers have a really hard time learning to recognize humor, which isn't surprising, since we don't always understand what makes us laugh to begin with. However, there has been some success in computation puns, likely because it is a relatively rule-defined type of joke. In a pun, you look for a word that has several definitions and use that in an ambiguous context. This is pretty straightforward and requires less creativity than some more involved joke forms. The bad joke eel meme often features puns because they are a classic dad-joke staple that we find somewhat amusing, but are often accompanied by a groan of "oh no not again."
It can then tell when jokes are not funny because there is no ambiguity and therefore no real element of surprise, much like in the anti-joke chicken meme. But the anti-joke chicken is still funny to us, simply due to the fact that the anticipation of the joke without the punchline causes us to be nervous and hence laugh, which is consistent with the relief theory. This can also apply to the incongruity theory in that there is a discrepancy between the setup and the punchline which makes us laugh upon discovery.
The theory of superiority explains why we find things like the forever alone meme funny because we take some joy in making fun of others. This is probably one of the more dismal theories of humor in that it says humans evolved the ability to laugh and make jokes simply in order to feel good about themselves at the expense of others.
The theory of how humor evolved and if computers and robots will ever be able to understand why the chicken crossed the road is relatively undiscovered, but it is crucial to our understanding of the evolution of complex human thought and emotion.