One should not recite the Amida in an open area, and one who does so is called “insolent” (Berakhot 34b), because in an open area one’s thoughts scatter, whereas in a private place place the King’s awe is upon her and her heart is humbled (SA 90:5). Furthermore, in an open space, there is concern that people will pass by and disturb her concentration. Those who are traveling may pray along their way, and if there are trees there, it is better to pray among them (MB 90:11). Similarly, it is preferable to pray next to a wall than in a completely open area (Eshel Avraham [Buczacz] 90:5). A courtyard surrounded by walls is considered a private place, almost like a house, since the defining factor is the presence of walls, not a ceiling (MB 90:12).
It is permissible le-khatĥila to pray in the plaza of the Kotel (the Western Wall) because it is surrounded by walls on three sides. Moreover, the holiness of the site reinforces one’s love and awe of God, causing one’s prayer to be said with more kavana. The patriarch Yitzĥak did this when he recited Minĥa on Mount Moriah, which was then an open field, as it says: “Yitzĥak went out to meditate in the field” (Bereishit 24:63; Berakhot 26b; Midrash Tehillim §81).
It is forbidden to pray in front of a synagogue because if person praying faces the direction of Jerusalem, her back will be disrespectfully turned towards the synagogue. If she faces the synagogue, her back will be turned to Jerusalem, in the opposite direction towards which the congregants inside are praying. However, one may pray alongside the synagogue or behind it when facing Jerusalem (SA 90:7).