I believe there are two key ingredients to memorable comedy.
One is that the character is trapped in his situation, but doesn't ever accept that feeling and fights it with every ounce of his being, and two is that there is pathos a millimetre under the surface which can surface very very briefly, and then re-submerge.
These scenarios apply to all the great comic reactions - Alf Garnett, Basil Fawlty, Hancock, Steptoe And Son, Victor Meldrew, Rigsby, I am sure there are more, but those always come to mind.
In Steptoe And Son, some of the early episodes were shot on one camera, with no edits, so they were effectively live theatre on TV.
The shots of Albert flashing from nasty to frightened and back again in a nanosecond, together with his shameless emotional blackmail of his trapped son were as great as anything Pinter or Brecht ever created.