What's worse than ten dead babies nailed to one tree?
One dead baby nailed to ten trees.
What's worse than ten dead babies nailed to one tree?
One dead baby nailed to ten trees.
The humor in this joke comes from the morbid absurdity of the situation. The setup uses a large number of dead babies, and then it changes the framing in the punchline to suggest something even more horrible by spreading the same tragedy over a larger number of trees. The unexpected punchline is the element of surprise and is deeply disturbing which leads to a dark humor effect.