"And the Lord appeared unto him, etc." (Genesis 18:1). Let our master teach us: How many blessings does a person pray each day? Thus our Rabbis taught: A person must pray eighteen. And why eighteen? Corresponding to the eighteen mentions of the Divine Name that are written in "Ascribe unto the Lord, O sons of might" (Psalms 29). They objected to Rabbi Levi: But in Babylon they say nineteen! He said to them: That one too is from the mentions of the Divine Name, as it is said, "The God of glory thunders" (Psalms 29:3). Rabbi Simon said: Corresponding to the eighteen vertebrae that are in the spine, for at the moment a person stands and prays he must bow with all of them, as it is said, "All my bones shall say, Lord, who is like You?" (Psalms 35:10). The Holy One, blessed be He, said: Be careful with prayer, for you have no quality finer than it; and even if a person is not [worthy enough] to be answered, I will do lovingkindness with him, for all My ways are lovingkindness. Rabbi Simlai said: Do you wish to know that all the ways of the Holy One, blessed be He, are lovingkindness? At the beginning of the Torah He adorned the bride, as it is said, "And the Lord God built the rib" (Genesis 2:22); and at its end, lovingkindness, for He buried the dead, as it is said, "And He buried him in the valley" (Deuteronomy 34:6); and in its middle He visited the sick, as it is said, "And the Lord appeared unto him." Once Abraham had circumcised himself, the Holy One, blessed be He, and His retinue came to visit him. From where? From what they read on the matter: "And the Lord appeared unto him."
Why the Amidah Has Eighteen Blessings and God's Ways of Lovingkindness
Midrash Tanchuma Buber, Vayera 1:1
וירא אליו ה' וגו' (בראשית יח א). ילמדנו רבינו, כמה ברכות מתפלל אדם בכל יום, כך שנו רבותינו, צריך אדם שיתפלל שמונה עשרה, ולמה י"ח, כנגד י"ח אזכרות שכתיב בהבו לה' בני אלים (תהלים כט). משיבין לר' לוי והא בבבל אומרים י"ט, אמר להם אף הוא מן האזכרות, שנאמר אל הכבוד הרעים (שם שם ג). אמר ר' סימון כנגד י"ח חוליות שבשדרה, שבשעה שאדם עומד ומתפלל צריך לשוח בכולן, שנאמר כל עצמותי תאמרנה ה' מי כמוך (שם לה י), אמר הקב"ה הוו זהירין בתפלה שאין לך מדה יפה הימנה, ואפילו אן אדם כדי לענות, חסד אני אעשה עמו, שכל דרכי חסד. אמר ר' שמלאי מבקש אתה לידע שכל דרכיו של הקב"ה חסד, בראשה של תורה קישט את הכלה, שנאמר ויבן ה' אלהים את הצלע (בראשית ב כב), ובסופה חסד שקיבר את המת, שנאמר ויקבר אותו בגיא (דברים לד ו), ובאמצעה ביקר את החולה, שנאמר וירא אליו ה'. כיון שמל אברהם בא הקב"ה ופמליא שלו לבקרו (שנאמר) [מנין ממה שקראו בענין] וירא אליו.