Rav Dimi said, anybody who visits the sick, causes that sick person to live, and if you don't visit the sick, then it causes that sick person to die. I believe that the answer to this is psycological in nature. When people become sick, they become depressed. Many times, the way how people get through depression, especially one induced by illness, is through the well wishes, visits and presence of other people. Thus, it can be said, that visiting a sick person will help to relieve them of their depression, and help their body to recover.
Many people become depressed to various degrees when they become sick.
The Gemara learns this out from a story that happened to Rabbi Akiva. One of Rabbi Akiva's students fell sick, yet none of the Chachamim came to visit him. However, Rabbi Akiva came to visit him. Rebbi, you caused me to live, meaning, you saved my life. This is because the visit will bring the sick person pain, as he will think that the other person is visiting just to witness the misfortune bestowed upon him.