The first step to answer this question is to try and establish what demon possession actually entailed.
The short answer is that people of Jesus’ day understood demons to be the cause of otherwise unexplainable ailments (a belief they had inherited from other cultures). For a more detailed analysis, please see the answer to this question: Why do OT and NT teachings on demons appear to differ?
With the benefit of our modern understanding we can see that these are simply different illnesses (physical or mental) the cause of which have now been worked out scientifically. In the case of Legion it seems that he suffered from some kind of schizophrenia.
And Jesus asked him, “What is your name?” He replied, “My name is Legion, for we are many.”
Jesus healed the man of his mental illness and then changed the behaviour of the pigs. This was obviously not a literal transference because mental illness doesn’t work like that. It isn’t like an infection that can be passed on, but importantly to the onlookers it would have appeared like it had been. The ‘demons’ would therefore have been drowned along with the pigs. It appears that Jesus did this to convince everyone, especially the man who was healed, that the demons had really gone.
The interesting outcomes for us surround the spiritual lessons Jesus was demonstrating to us:
- Jesus is Lord, even over the most complex of human conditions, and God has given him the power to heal
- Jesus’ healing is final. The sight of the pigs disappearing under the water told Legion that he had been cured for good
- Jesus’ healing should bring about a response
And he went away and began to proclaim in the Decapolis how much Jesus had done for him, and everyone marveled.