The line is spoken by Jaques (the melancholy lord) in Act 2, Scene 7 of As You Like It, during his "Seven Ages of Man" speech.