paulb says, A key part of the plot of Gilbert & Sullivan's The Pirates of Penzance rests on the [confusion of] pronunciation of, respectively, 'often' and 'orphan', which suggests that in the late 19th century both words sounded similar...

Part of that (I think?) is that the pirates speak in a lower-class accent, so that the "of" of "often" would sound like the "or" of orphan.

And part of the humor is the contrast between their earthy speech and the prissiness of their interlocutor, Major General Stanley. The humor of rough men speaking in high-falutin' language recurs throughout the libretto.