Imagine living in a world where every home was teeming with dangerous beasts. Tiny, deadly creatures chewed through food rations, infrastructure, and sometimes they ate human beings. If it weren't for cats, these beasts likely would have taken over.
One of the earliest Egyptian deities was the goddess Madfet. This goddess was recognized primarily by individuals that were seeking protection or sanctity from venomous animals like snakes and scorpions.
Madfet appeared in a feline form but also showed herself as a woman with the head of a lion, cheetah, or house cat (she was also shown as a cat with a woman's head, but that was a little less frequent than the latter).
Madfet was considered to be the protector of the home, and therefore the protector of the kingdom as a whole.
As the Egyptian people domesticated their cast, they made sure to make them feel like valued family members as opposed to semi-feral protectors of the home.
The goddess Madfet evolved into being the goddess Bastet. Much like Madfet, Bastet was the goddess of protecting the home, but she also represented the sun god. Her followers called her the "Eye of Ra."
The Egyptian people gave Basted the position as the sun god because she fiercely watched over Egypt to protect them from invasion (which was true, cat's would attack invaders), pestilence (cats ate rats, who carried diseases), and famine (cats prevented rodents and other parasites from destroying crops).