There is some connection between music and comedy (or at least joke punchlines, like many, I'm not convinced this theory explains how all comedy works): Musical structure almost always relies on establishing a pattern (repetition) and breaking it (contrast).