What occasion prompted Hashem to visit Avraham?
Rashi and Targum Yonasan: It was the third day after the B'ris Milah (when Avraham was in pain
When the pain is the most intense - as we find in the episode of Sh'chem - in Parshas Vayishlach..
Rashi says so, for this revelation was not accompanied by any prophecy or command. Rosh derives that it is a Mitzvah to visit the sick even without talking, e.g. he was sleeping (he is happy when they tell him that someone visited). Bechor Shor rejects Rashi (refer to 18:1:1:5). We find that Hashem also clothed the naked (when He made clothes for Adam and Chavah), comforted mourners (Yitzchak after the death of his father Avraham) and buried the dead (Moshe Rabeinu) - Sotah 14a.
The author cites many examples of Hashem appearing to various people as a reward, among them following Keri'as Yam-Suf, where, based on the Pasuk "Zeh Keli ve'Anvehu", Chazal explain that every maidservant there saw the Shechinah in a way that Yechezkel ha'Navi did not merit to see - as a reward because "They believed in Hashem and in Moshe His servant!"
See Devarim 29:9-11. Perhaps that is why we prepare a special chair (Kisei shel Eliyahu) at every B'ris (Seforno).
Seeing as a Shali'ach is like the sender, and the Pasuk writes in Mishpatim, Sh'mos (23:21) "Because My name is within Him" (the angel).
According to the Rambam, this entire episode was a prophetic dream, without any angels having been present. However the Ramban strongly criticizes this explanation. He also disagrees with the Ramban's theory that every revelation of an angel denotes a prophecy. And he discusses at length the differences between Moshe Rabeinu and all the other prophets. Refer also to 12:17:1:1.
Why did Hashem appear to Avraham specifically in the territory of Mamrei?
Rashi: Because he was the one to offer him advice with regard to the B'ris Milah.
Rashi said that Mamrei advised him about Bris Milah How is it possible that Avraham, who passed all ten of the superhuman tests that Hashem sent him, should ask advice regarding Hashem's command?
Da'as Zekeinim #1, Moshav Zekenim #1, Riva #1: He asked him, not as to whether to perform the Milah, but) whether to do it secretly or in public. 1
Da'as Zekeinim #3: He asked him what he should do in the event that the members of his household refused to be circumcised. 4
Moshav Zekenim #3, Hadar Zekenim #2, Rosh (on Bereishis 17:13): All the babies that Avraham circumcised before he himself was circumcised died. Mamrei expounded "Himol Yimol" - only one who is circumcised can circumcise others. 5
Riva #3 citing Chizkuni, Moshav Zekenim #4: Avraham merely tested Mamrei.
Moshav Zekenim #5, Hadar Zekenim #3: Avraham did not know whether to cut at the end of the Ever, or around it. Mamrei advised to cut both, leaving it exposed all around, like Alon (oak). This is why it says "b'Elonei Mamrei." 6
Kol Eliyahu, Divrei Eliyahu: Avraham brought many people to observe seven pleasant Mitzvos of Hashem. He thought that this will cease if he circumcises all males. He thought that to sacrifice his reward, not circumcise, and bring more people to serve Hashem. Mamrei told him to obey Hashem's command.
Shlah Vayera, Derech Chayim 29: Avraham was unsure if he should circumcise immediately, or wait for Hashem to command him. Mamrei advised him to wait, for one who is commanded and fulfills is greater.
Mamrei advised him to do it publicly, so that people would take their cue from him (perhaps 'people' refers to the Bnei Yishmael and the Bnei Keturah). "B'Etzem ha'Yom ha'Zeh" connotes the middle of the day. (Refer to 17:23:2:2, refer to 17:2:2:3.)
Aner and Eshkol did not know what to answer - Mamrei advised him (here) to perform the Milah on the part of the body where there is a distinction between a male and a female (Refer to 17:14:1:1).
Riva rejects this, for Midrash Tanchuma says that Hashem explicitly told Avraham, or Avraham himself derived this.
Here, Mamrei advised him to first circumcise himself and Yishmael, and the others would follow automatically, as is implied at the end of Lech Lecha (See 17:26:2:1).
Moshav Zekenim asks how Avraham, who understood all Mitzvos, could not expound this himself! However, 'we do not question the Drashah.'
Also Riva brings like this answer.
What was Avraham doing sitting outside on the third day after his Milah?
Rashi: He was eagerly awaiting guests - in spite of his physical condition and in spite of the heat. 1
Why does the Torah see fit to add "ke'Chom ha'Yom"?
Rashi: Hashem 'took the sun out of its bag', making it so hot that nobody was able to venture outside. Consequently, when Avraham was pained 1 that there no guests, Hashem was forced to send angels to visit him.
Rashbam: To explain why Avraham did not invite them to stay overnight, like Lot did - because visitors who arrive during the hot late morning hours tend to stay for a meal and leave.
Da'as Zekenim: It was at four hours of the day, which is the standard mealtime.
Hadar Zekenim: This alludes to the future day of judgment. Avraham sits at the entrance to Gehinom, to remove [Yisraelim].