Mishneh Torah, Prayer and the Priestly Blessing 11:9-10
משנה תורה, הלכות תפילה וברכת כהנים י״א:ט׳-י׳
Mishneh Torah, Prayer and the Priestly Blessing 11:9-10
Rambam addresses the proper use of a synagogue and the restrictions on its sale and repurposing, again reflecting that it has an elevated sanctity akin to sacred space.
מִי שֶׁצָּרִיךְ לִכָּנֵס לְבֵית הַכְּנֶסֶת לִקְרוֹת תִּינוֹק אוֹ חֲבֵרוֹ יִכָּנֵס וְיִקְרָא מְעַט אוֹ יֹאמַר שְׁמוּעָה וְאַחַר כָּךְ יִקְרָא חֲבֵרוֹ כְּדֵי שֶׁלֹּא יִכָּנֵס בִּשְׁבִיל חֲפָצָיו בִּלְבַד. וְאִם אֵינוֹ יוֹדֵעַ יֹאמַר לְתִינוֹק מִן הַתִּינוֹקוֹת קְרָא לִי הַפָּסוּק שֶׁאַתָּה קוֹרֵא בּוֹ. אוֹ יִשְׁהֶה מְעַט בְּבֵית הַכְּנֶסֶת וְאַחַר כָּךְ יֵצֵא. שֶׁהַיְשִׁיבָה שָׁם מֵעִסְקֵי הַמִּצְוֹת הִיא שֶׁנֶּאֱמַר (תהילים פד ה) ״אַשְׁרֵי יוֹשְׁבֵי בֵיתֶךָ״ וְגוֹ׳:
A person who has to enter a synagogue to call a child or his friend should enter and read [a portion of the written law] or relate a teaching [of the oral law] and then call his friend, so that he will not have entered [a synagogue] for his personal reasons alone. If he does not know [how to study], he should ask one of the children [to] tell him the verse he is studying or, [at the very least,] wait a while in the synagogue and then leave, since spending time [in the synagogue] is one of the aspects of the mitzvah as implied by [Psalms 84:5]: "Happy are those who dwell in Your house."