The Rishonim discuss whether bikur cholim is a mitzvah from the Torah or a mitzvah d'rabbanan. Many sources imply that bikur cholim is a Torah obligation. If the basis for bikur cholim is chesed, then it is a mitzvah from the Torah, as it falls under the umbrella mitzvah of כמוך לרעך ואהבת, "Love your fellow man like yourself." Furthermore, it states (Devarim 28:9), בדרכיו והלכת, "You shall go in His ways," and it states (Devarim 13:5), אלקיכם 'ה אחרי תלכו, "After Hashem your G-d shall you follow," and Chazal explain this to mean that we should follow Hashem's ways by visiting the ill and performing other forms of chesed.
According to some Rishonim, the mitzvah of bikur cholim is expressed in parashas Korach (Bamidbar 16:29). Moshe said, יפקד אדם כל ופקודת עליהם, "If the destiny of all men has visited upon them." The Gemara (Nedarim 39:) explains, "If they die like all ill people, who lie on their beds and people come to visit them..." (נדרים הלכות ז"ריא).
Another popular source is in this week's parashah (18:20), בה ילכו הדרך את להם והודעת, "You shall make known to them the path on which they should go..." The Gemara (Bava Metzia 30:) says that this refers to visiting the ill.
The Gemara (Nedarim 40.) relates that a student of Reb Akiva's yeshiva was ill, and the students of the yeshiva weren't coming to visit him, so Reb Akiva, himself, went to visit his student. Reb Akiva tidied up the room, washed the floors, and the sick student said, "Rebbe, you granted me life." "Reb Akiva went out and taught his students, 'Whoever doesn’t visit the sick, it is like murder, and whoever visits the sick brings him life.’"
The Seder HaYom writes, "Bikur cholim is the from the highest forms of gemilus chasadim, as Chazal (Nedarim 39:) write, 'Bikur cholim has no limit (שיעור להם אין).' Sometimes, with clever, encouraging, and kind words, one can revive a sick person and grant him life. We have seen this happen many times. Sometimes a person visits the sick for an hour or two, and the ill person says, 'I feel like a new person. My neshamah came back to me,' and we see that the illness became lighter."
It states (Mishlei 18:14), ורוח מחלהו יכלכל איש רוח ישאנה מי נכאה, "A man's spirit will sustain his sickness, but who can support a broken spirit." The Vilna Gaon zt'l explains that ruach means happiness. "When a person is happy, he can handle his illness... His joy will annul it. But when one is sad, who can carry it?" Therefore, part of the mitzvah of bikur cholim is to give the ill person hope and happiness.
The Rambam writes, "Tell an ill person happy stories that will gladden his heart. Tell him interesting news that will take his mind off his illness. Make him laugh, and the people caring for him laugh. When you choose someone to be with a sick person, choose someone who can make him happy because this is what is needed."
Sodi Razyah (attributed to the Rokeach) writes, "When one visits the sick, he should speak comforting and encouraging words." These encouraging words will bring joy and, at times, refuah, too.
The Gemara (Nedarim 40.) writes the many rewards of visiting and caring for the ill. Among them is that he will be saved from Gehinom, and is granted long life, protection from the yetzer hara, and is saved from afflictions. Everyone honors him, and he will have good friends who give him good counsel, and he will be saved from bad friends who give bad counsel.
9. Every year, Baron Rothschild z'l would visit the Ksav Sofer zt'l at a vacation/health resort they both frequented. One year, the Ksav Sofer wasn't feeling well, and the Baron cut his visit short. The Ksav Sofer asked him why he wasn't staying longer. The Baron replied, "Chazal call visiting the sick (18:20)ילכו , 'to go.' This is because when you visit the sick, you must know when to leave. Sometimes a visit is a burden on the ill person, and sometimes the ill person is embarrassed to be seen in his state. Therefore, the Torah says ילכו, that you have to know when to leave." The Ksav Sofer often repeated this vort that he heard from Baron Rothschild.