The fast of Karva Chauth is kept by Hindu women for the well-being, prosperity and longevity of their husbands. The origin of this festival is based upon a very sweet and noble idea. In earlier times, girls would get married at a very young age, and had to go and live with their in-laws in other villages far away from their own parents. If she had any problems with her husband or in-laws, she would have no one to talk to or seek support from.
Thus, there grew a custom where the bride would befriend another woman to share her joys and sorrows. Their friendship would be sanctified through a small Hindu ceremony right during the marriage. Once the bride and the woman became god-friends or god-sisters as they are commonly known, they would remain so all their lives and recognize the relation as such. They would also treat each other like real sisters.
After becoming friends, they would share all their joys, sorrows and problems with each other. Thus, Karva Chauth started as a festival to celebrate this friendship (relationship) between the brides and their god-friends (god-sisters). Praying and fasting for the sake of husband came later and was secondary.
It was probably added, along with other mythical tales, to enhance the festival. In any case, 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 the celebration of her relationship with the god-friend would be quite logical.