A fascinating look at why we often repeat what hurts us—even when we know better.