The Mitzvah to Pray in a Synagogue
When a person prays in a synagogue with a congregation, his prayer is heard (see Berachot6a).
Even someone who missed praying in a minyan has a mitzvah to pray in the synagogue, since it is a permanent and special place of holiness in where prayer is more accepted.
However, when the minyan is held in a different place, it is preferable to pray with theminyan rather than individually in the synagogue. If there is a small minyan in the synagogue and a larger minyan elsewhere, although there is merit to praying in the company of many, the value of praying in a synagogue is greater.
Every community has an obligation to fulfill the mitzvah of building a synagogue which will be their mikdash me’at and where people can pray in a minyan. As it is written (Ezekiel 11:16), “I have been for them a small sanctuary,” and Rabbi Yitzchak interpreted, “These are synagogues and study halls” (Megillah 29a).
It is a mitzvah to run to synagogue just as it is a mitzvah to run to perform every mitzvah, in order to express one’s passion for matters of sanctity, as it says (Hosea 6:3), “We will race on in order to know Hashem.”
Likewise, when one leaves the synagogue, he should walk slowly, so that he not appear happy to leave the synagogue (Shulchan Aruch 90:12).