When it comes to demonic possession, three different factors play a part in its manifestation: disease, mental illness, and religious pressure. In the case of incidents such as the Salem witch trials, food-borne disease likely caused the townspeople to hallucinate instances of witchcraft.
In a case like the one that inspired The Exorcism of Emily Rose, the "possessed victim" actually suffered from epilepsy, a condition further exacerbated by taking the victim off her medication.
Furthermore, the common depiction of possessed victims regurgitating bile might be explained by allotriophagy, a condition where a person desires to consume abnormal foods, which would naturally lead to vomiting.
Meanwhile, religious pressure may conversely lead to the evils it so seeks to vanquish from demonic possessions. The looming threat of a higher institution and vengeful deities weighs down heavily on many religious people, and can cause mental breaks. So while the supernatural provided the past explanation for possessions of the past, science may provide the answers for future cases.
Partake in the collision between science and the supernatural with the chilling video below.