One line of historic thought says it has nothing to do with wanting anybody's soul. In fact, they really want to share in someone's unhappiness, the thinking goes.
Good health means keeping everything in balance, and sickness means an excess of one of the humors.
Demons, Hippocrates thought, like to drink black bile. Since an excess of black bile causes emotional depression, demons will inhabit the bodies of unhappy people in order to get at all the extra bile they have.