What is the origin of the knock-knock joke?
Some claim they originated in the Middle Ages as a call-and-answer password format. Others, as @Callithumpian notes, cite passages in Shakespeare.
Here is a legitimate reference to their existence in America in 1936:
This is the first legitimate printed reference I can find.
I found this use of the joke in the printed "Proceedings" of the American Pomological Society. This publication seems to cover meetings from 1933 to 1937, but this occurrence is early enough (p. 75) that I think it can be dated to 1933. I wondered if this was perhaps used as a jingle by an apple company, but I couldn't find evidence of this.
Whatever the origin of the first joke, its form certainly came from Macbeth: