The Messenger of Allah ﷺ said, "Do not prevent your women from going to the mosques, though their homes are better for them."
حدثنا عثمان بن أبي شيبة حدثنا يزيد بن هارون أخبرنا العوام بن حوشب حدثني حبيب بن أبي ثابت
قال رسول الله ﷺ لا تمنعوا نساءكم المساجد وبيوتهن خير لهن
[Sahih] Ahmad narrated it, 2/76, from Yazid bin Harun with this wording. Ibn Khuzayma graded it sahih, no. 1684, and Hakim did likewise, according to the criteria of the two Shaykhs, 1/209, and Dhahabi agreed with him. The hadith has supporting narrations in Bayhaqi, 3/131, and elsewhere.