A ha-ha is either an abrupt laugh or a wall that's sunken into the ground so that people can see over it. And if you find sunken walls humorous, you can let out a ha-ha when you see a ha-ha.
You might respond to a joke with a ha-ha, or say it sarcastically when your brother tells his dumb knock-knock joke again. Landscape designers use ha-ha in a completely different way: it's a kind of ditch with a retaining wall built into it. Ha-has were historically used to keep grazing animals out of gardens while providing the illusion of uninterrupted expanses of lawn. The name comes from the expression of surprise as someone discovers the hidden wall.