The ha-ha is a bizarre architectural feature common in ornamental gardens: it’s a ditch that’s designed to be nearly invisible from one side. Presumably it gets its name from the garden-owner’s reaction when visitors stumble into the ditch.
In real life, ha-has are used to enclose livestock without breaking sight lines. In D&D, I presume that they’re a goblin invention. They’re named so because goblins find it so funny when human invaders fall into hidden pits.
In one game I ran, I gave the PCs a goblin-drawn map of a dungeon. The hidden pits were all marked as “ha-ha.” However, goblins find so many other things funny: sharpened pendulums, poisoned meat, patches of green slime on a green carpet: and they note them all with various onomatopoeia for laughter. On a goblin map, treat “ha-ha,” “har-har”, “hee-hee”, or “lol” as “find an alternate route.”