The dramatic line ‘Alas, poor Yorick! I knew him, Horatio’ comes from Shakespeare’s Hamlet. Hamlet speaks the line in a graveyard, as a meditation on the fragility of life, as he looks at the skull of Yorick.
Yorick was a court jester he had known as a child, and he grieves for him. In this complex speech, which is one of the best known in all dramatic works, Hamlet goes on to consider the fate of us all when he compares the skull to those still living: “let her paint [her face] an inch thick, to this favour [state] she must come”
As a child Hamlet found the jester Yorick amusing and entertaining. They used to play and frolic in an intimate but innocent way. Now that Yorick is a stinking corpse the memory of touching him seems revolting and makes Hamlet feel ill.