The Messenger of Allah (sal Allahu alaihi wa sallam) said: “It is better for a woman to offer her Salat in her bedroom than in her living room; and it is better for her to offer her Salat in her living room than in her courtyard.” [Abu Dawud]
However, it is permissible for women to come out of their homes when necessary and it is permissible for them to go to the Masjid, provided that they cover themselves properly and do not wear perfume, noisy ornaments, or anything else that attracts attention to themselves.
Aisha (radi Allahu anha) said: “The women of Bani Israeel used to make wooden sandals which they wore to their places of worship, and they used to provide attractions for men; so Allah forbade them to go to the Masjid. [Musnad Abdur Razzaq]
In another Hadith we find this saying of Aisha (radi Allahu anha): “If the Prophet (sal Allahu alaihi wa sallam) had seen the attitude of women which they adopted after him, he would have surely stopped them from coming to the Masjid as the women of Bani Israeel were stopped.” [Muslim]
When Allah (subhana wa ta’ala) is telling me that it is better for me to offer my prayers at home than in the Masjid, I need to seriously ask myself why I’m going to the Masjid, if I am.