The Gemara[1] says:
... One may not visit the sick on the Sabbath.[2] These are the words
of Beis Shammal — But Beis Hillel permits these activities on the
Shabbath.[3]
Hillel says we should visit the sick because these are acts of kindness (Aruch HaShulchan, Orach Chaim 287:1). Jews are even encouraged to visit and pray for the recovery of non-Jews (Shulchan Aruch, Yoreh Deah 151:12). Just as G-d, The Holy One, visited Abraham when the patriarch was sick (Chapter 18 Genesis), so, too, we should visit the sick. This is called called “imitatio deo.”
The Holy One, blessed be He, visited the sick ... so should you visit
the sick (Midrash Sifrei; Babylonian Talmud, Sotah 14a).
The Gemara cites a Baraisa about visiting the sick on the Shabbath:
The Sages taught in a Baraisa: One who enters to visit a sick person
on the Shabbath SHOULD say: "It is the Shabbath now, therefore we are
prevented from crying out for your recovery, but recovery will come
soon."
This means that we should not pray to G-d on his behalf since this prayer will arouse weeping and sorrow. Rather, we are to offer him hope to lift his spirits (Ran).
And R' Meir says: One should say "[The Sabbath] itself can have mercy
and bring your recovery."
This means that if the sick person honors the Shabbat, perhaps he will merit a fast recovery. Thus, the Shabbat does not delay recovery but hastens it unaided by prayer (Maharsha)[4].
R' Yehudah says: One should say: "May the Omnipresent have mercy on
you and on the sick of Israel." R' Yose says: "May the Omnipresent
have mercy on you among the sick of Israel."[5]
By using Rabbi Yose's formula which groups the sick person together with the sick of Israel, the prayer, offered on the behalf of many, becomes a dual prayer (Rashi). Although R' Yehudah and Yose agree with the Tannaim that this prayer should not be directed to G-d on the Shabbat (Maharsha).
When Shevna, a prominent person in Jerusalem, would enter to visit a
sick person on the Shabbat, he would say: "Peace." And when leaving, he
would say: "The Shababth prevents us from crying out for your
recovery, but recovery will come soon. [G-d's] mercies are many, and
rest on the Sabbath in peace."
This means that G-d's mercies are so great that He will heal the sick on the Shabbat even without prayer. The person must observe Shabbat in peace. Shevna suggests one begins and ends their visit with the word shalom (peace), which is a Name of G-d.[6]
The Gemara specifies which of these Tannaic opinions is the source for
the following Amoraic statement:
With whom does this teaching states by R' Chanina accord? One who has
a sick person in his household must include him together with the sick
of Israel when praying on his behalf. With whom does this teaching
accord? It accords with R' Yose. (This is the view of R' Yose). the
Gemara cites another teaching by R' Chanina on this topic: And R'
Chanina said: It was with difficulty that [the Rabbis] permitted one
to console mourners and to visit the sick on the Shabbath (because of
the distress felt by the visitors (Rashi).
Also, a person requires the assistance of the ministering angels to send his prayers to G-d (Rashi to Sotah 33a, see also Rabbeinu Yonah to Berachos folio 7a).
[1] Talmud Bavli 12a4 (tractate Shabbos, the Artscroll addition)
[2] Because this activity causes anguish (Rashi, see Rif and Ran)
[3] Hillel referred to Isaiah's words "your business" to mean that personal needs are forbidden but not a mitzvah
[4] Although he must ignore his pian
[5] Babylonian Talmud, Shabbat 12b1
[6] See 10b (Maharsha)