It was narrated that ‘Aa’ishah(RA) said: “The Messenger of Allaah (peace and blessings of Allaah be upon him) commanded that mosques should be built among the houses (i.e., in each neighbourhood), and that they should be cleaned and perfumed.” (narrated by al-Tirmidhi, 594; classed as saheeh by al-Albaani in Saheeh al-Targheeb wa’l-Tarheeb, 279).
The Blessed Prophet(sallallahu alayhi wasallam) said, “Whosoever removes adhaa (anything repulsive or harmful) from the Masjid, Allah will make a house for him in Jannah.” (ibn majah)
The Prophet (sallallahu alayhi wasallam) passed by a grave and asked his companions about it. His companions replied it is the grave of Umm Muhjan. The Prophet (S) rebuked them because they did not inform him of her death and then prayed the funeral prayer over her. He then said: ‘Why did you not inform me?’ They replied- you were sleeping and we did not like to wake you’. The Prophet prayed for her and had great respect for her as she used to spend her efforts in cleaning the house of Allah and the Prophet’s masjid.” (Related by Muslim)
It was narrated from Abu Hurayrah that a black man (or a black woman) used to clean the mosque, and he died. The Prophet (sallallahu alayhi wasallam) asked about him, and they said that he had died. He said, “Why did you not tell me? Show me his grave.” (Or he said, “her grave.”) So he went to her grave and offered the funeral prayer for her. (Narrated by al-Bukhaari, 458; Muslim, 956).
Ibn Hajar said in Fath al-Baari, “The hadeeth indicates the virtue of cleaning the mosque, inquiring after servants and after friends if they are absent.”
"Spitting in the Masjid is a sin and its expiation is clean it." When the prophet (S.A.W.) saw a spit in the Masjid, he used to remove it with a stone. The companions of the prophet (S.A.W.) used keep the Masjid clean. Imam Abu Dawod reported that Abdullah bin Omar (R.A.) used to put perfume inside the Masjid when Omar (R.A.) sat on the Minbar to deliver Friday speech.