In the very earliest Christian communities, there were women who dedicated their lives to emulating Jesus Christ. These women tended to be virgins or widows, and they called themselves "spouses of Christ" or "brides of Christ." They began wearing veils to symbolize their marriage to Jesus; the earliest habits were also made of very rough cloth, out of solidarity for the poor. Women who elected to live in this way spent their days in prayer, made penitent acts and performed manual labor. Even in the first century, the women's choice to remain chaste was seen as radical, though these early religious women did command respect for their choice among fellow Christians.
In the fourth century, monks began living in community with each other, and the brides of Christ followed suit, often forming a joint partnership with local monks so that their convent would sit next to a monastery. Each community was -- and remains -- different from another. Some monks and nuns vowed never to leave their cloisters so that they could dedicate themselves more fully to prayer, while some orders took on apostolic work beyond their gates. It was during this time period that the first official vows of poverty, chastity and obedience were taken, though the women had been upholding these standards from the beginning.
For some women, entering a convent was a good way to avoid marriage; some feminist scholars have interpreted these women's vow of chastity as a means for pursuing leadership and individual interests that they wouldn't have been allowed otherwise. Convents may have also been a convenient escape for battered women and former prostitutes who would have been shunned by society, and a convent usually provided fairly advanced education for girls at the time. For other women, the choice to enter a convent wasn't theirs to make. Parents would often offer a young daughter to a convent as an oblate, or as a promised nun. This practice would continue for several centuries; the dowry that parents paid to a convent was usually just a fraction of what would be paid to a prospective husband, so convents became dumping grounds for the more unmarriageable ladies of a large family.
Women who were sent to the convent who would have rather become wives and mothers were often put in charge of dolls that looked like Jesus, which they would take care of on certain holy days. Meanwhile, there were plenty of nuns that did experience motherhood, thanks to the convent's close association with some monasteries. But in 1298, a pope would put a stop to all that.