In order to understand the many sayings of our Sages about the importance and nature of visiting the sick, we have to preface one basic insight. Our Sages definitely did not view illness as something natural. Illness, as a deviation from the normal, is considered a time of extraordinary providence a time when HaShem is examining us more carefully.
On the one hand this special providence carries a special danger: A person should always pray that he shouldnt fall sick, for if he becomes sick, he is told, bring a merit and free yourself (Shabbat 32b). The sick person is suddenly saddled with the burden of proof to demonstrate that he deserves life and health.
On the other hand HaShem's scrutiny is a kind of privilege, and we learn that the Divine presence supports the sick person and stands over his bed (Shabbat 12b). For this reason when we visit the sick we shouldn't sit much elevated over him (SA YD 335:3).
The main mitzva of visiting the sick is to tend to the needs of the sick person. This is evident from the Hebrew term bikur cholim whose literal meaning is not visiting the sick but rather looking after them. This obviously has a positive effect on the sick persons condition.
But visiting the sick also has a spiritual effect on the patients condition. Our Sages explain that performing acts of kindness is a way of cleaving to the Divine presence, because we are going in the ways of G-d Who constantly acts with loving kindness towards His creatures (Sota 14a). In this way the aspect of Divine kindness is among us, as it is aroused through our own actions, and this affects the judgment of the sick person.
ONE OF HIS COHORT
The Talmud states that visiting the sick is a mitzva even for one of the sick person's age, or cohort (ben gilo), who takes with him part of the illness. The meaning seems to be that the visitor himself may become somewhat ill (Bava Metzi'a 30b). We can understand this based on a Midrash which suggests that age cohorts and groups are sometimes judged collectively. Rebbe Yochanan said in the name of Rebbe Shimon ben Yehotzadak, The Holy One, blessed be He, brings into the world ages and groups. If one of the age dies, all of that age should worry; if one of the group dies, all of the group should worry (Ruth Rabba 2:8).
We already explained that sickness is an occasion for judgment and scrutiny. When someone of the sick person's cohort also visits the sick person and groups himself together with him, it is as if he is inviting to be judged together with him. On the one hand, this brings upon the visitor part of the illness. On the other hand, it ameliorates the misfortune on the whole, because it is basic principle of Judaism that the community is judged more leniently than the individual.
The Talmud states that one who visits a sick person merits four blessings: he is saved from the evil impulse, and from suffering, he will receive honor, and be blessed with faithful friends (Nedarim 40a). The Maharal explains that these correspond to the blessings of the sick person himself: a sick person is not troubled by the evil urge, and the visitor alleviates his suffering, honors him with his visit, and is a faithful friend to him (Netivot Olam Netiv Gemilut Chasadim 4).