For Men:
It is an act of great reward to perform Salah in congregation at the Masjid. It is highly recommended and considered a great Sunnah and all men should strive to do so:
1064. Ibn `Umar (May Allah be pleased with them) reported: The Messenger of Allah (PBUH) said, "Salat in congregation is twenty-seven times more meritorious than a Salat performed individually.''
[Al-Bukhari and Muslim].
1065. Abu Hurairah (May Allah be pleased with him) reported: The Messenger of Allah (PBUH) said, "A man's Salat in congregation is twenty-five times more rewarding than his Salat at home or in his shop, and that is because when he performs his Wudu' properly and proceeds towards the mosque with the purpose of performing Salat in congregation, he does not take a step without being raised a degree (in rank) for it and having a sin remitted for it, till he enters the mosque. When he is performing Salat, the angels continue to invoke Blessings of Allah on him as long as he is in his place of worship in a state of Wudu'. They say: `O Allah! Have mercy on him! O Allah! Forgive him.' He is deemed to be engaged in Salat as long as he waits for it.''
[Al-Bukhari and Muslim].
For Women:
It is superior and better to perform Salah at home, however it is not forbidden for them to come to the Masjid:
Narrated Umm Humaid As-Sa’diyah who once said to the Prophet (SAW): Messenger of Allah (SAW)! I love to pray with you (i.e. in the mosque)! Upon hearing this, Allah’s Messenger (SAW) said:
"I know that you love to say your prayer with me. However, the prayer you offer in your residence is more excellent than that you offer in your people’s mosque. And your prayer in your people’s mosque is better for you than you prayer in the (lager) congregational mosque." (Abu Dawud; Musnad of Imaam Ahmad; & At-Tabarani)
Ibn ‘Umar reported: The Messenger of Allah (SAW) said:
"Do not prevent women from going to the Mosque at night." A boy said to ‘Abd Allah bin ‘Umar: We would never let them go out, that they may not be caught in evil. He (the narrator) said: Ibn ‘Umar reprimanded him and said: I am saying that the Messenger of Allah (SAW) said this, but you say: We would not allow! (Saheeh Muslim)
Zainab bint Thaqafiya reported: The Messenger of Allah (SAW) said to us:
"When any of you comes to the mosque, she should not apply perfume." (Saheeh Muslim)