When is a door not a door? When it's ajar!
This is one of the oldest jokes I know. My grandparents told it to me when I was a young child. In my mind it still has same whiff of cosy, old-fashioned comfort as all my memories of them. Does anyway say "ajar" anymore?
As a joke this is about as far away from dangerous as I can imagine. A simple, quaint, old-fashioned play on words. A door isn't a door when it's a jar. Hohoho!
So where's the danger?
Well, I think, perhaps because of its mildness, this joke is actually the perfect exemplar for one of the key forms of danger that joking is often about.
I saw an episode of Star Trek once where, completely unexpectedly, Captain Kirk woke up entirely unable to understand the language of the other people on the Enterprise. And they couldn't understand him either. To him, everything they said sounded like gobbledegook, and his speech sounded the same to them. Of course, being Star Trek, this situation was all nicely resolved in a tidy 50mins (apparently it was aliens) but what stuck with me was the initial moment of realisation, the horrible feeling of being thrown into a situation where you can't make yourself understood.
That is what I think this joke is about. It speaks to a very basic fear of not being able to understand or be understood. It is about how transitory and ephemeral the meaning of words can be, and how easy is it to imagine a situation where our language fails us completely and no-one can understand a word we say.
Imagine for a moment if the word "ajar" didn't exist. The punchline to this joke would be entirely nonsensical. For example, a similar construction with different words might be: "When is a ball not a ball, when it's a horse." Now imagine someone presenting that sentence to you seriously, you would have to conclude that either they were not mentally OK, or maybe you weren't. Either way, the chances of you and this person cooperating, or even tolerating each other, would be severely diminished and to your lizard brain that doesn't look good.
When we make puns we are tickling that fear, and although this is probably the mildest version of that, this is where I think the humour lies. This is a violation of that idea that language is reliable and understandable, but it is immediately made benign by us spotting both meanings and seeing how we were fooled.