In the ancient time, girls used to get married at a very early stage, and had to go and live with their in-laws in other villages. After marriage, if she faces any problem with her in-laws or her husband, she would have no one to talk to or seek support from. There used to be no telephones, buses and trains long ago. Her own parents and relatives would be quite far and unreachable. Thus the custom started that, at the time of marriage, when bride would reach her in-laws, she would befriend another woman there who would be her friend or sister for life. It would be like god-friends or god-sisters. Their friendship would be sanctified through a small Hindu ceremony right during the marriage.
Once the bride and this woman had become god-friends or god-sisters, they would remain so all their lives and recognize the relation as such. They would also treat each other like real sisters.
Later in life, if she faces any difficulty related to her husband or in-laws, she would be able to confidently talk or seek help from each other. Thus, Karwa Chauth was started to as a festival to celebrate this relationship between the once-brides and their god-friends (god-sisters). Fasting and praying for husband came later and is secondary. It was probably added, along with other mythical tales, to enhance the festival. The husband would always be associated with this festival, because the day of starting this holy friendship between two god-sisters was essentially the day of bride’s marriage to him. Thus, praying and fasting for him by his wife during a celebration of her relationship with the god-friend would be quite logical.
Hence, the festival of Karwa Chauth was to renew and celebrate the relationship between god-friends (god-sisters). It had a tremendous social and cultural significance when world was not having the way to communicate and move around easily.