A new study found that subtle differences in an animal’s behavior by midlife can predict how long it is likely to live.