A comic story, play, or novel usually pivots on hyperbole (exaggeration) and reversal of expectations, and in this story, O'Henry does not disappoint.
Sam and Bill think it will be easy money for them to kidnap little Johnny and exact a handsome ransom from his father, the wealthy Mr. Dorset.
The comedic elements lie in the exaggerated way everything goes contrary to expectation. Johnny shows no reluctance to be kidnapped but comes along happily. Rather than terrifying the little Johnny by kidnapping him, the little boy terrifies his kidnappers. He attempts to scalp Bill as part of an Indian game, and attacks his kidnappers with a hot potato and a rock. By the end of the story, rather than getting a ransom, the hapless kidnapper duo pays Mr. Dorset $250 to take the wildly energetic child off their hands.
We laugh because this is a classic trickster tale, in which the seemingly powerless person bests the two who appear to hold all the power.