Edgar Allen Poe, Sigmund Freud and cognitive scientists have all wrestled with the human tendency to behave in ways that are irrational and self-defeating