In his book The Pun Also Rises, How the Humble Pun Revolutionized Language, Changed History, and Made Wordplay More Than Some Antics, John Pollock gives us a short, but informative history of the pun. In the first part of the book he describes the various types of puns.
In the 2nd part he explains how our brains learn language and in the last part he relates the history of punning and takes us back to the beginning when man first began to pun.