You get to exercise your ancestral proclivity to hunt mice and small birds. You get to eat what you hunt.
You don't have to stay in the humans' house, they'll make a hole in their own dwelling just for you. And they won't mind if you go out, just like their teenager.
If you don't find more food than you need, the humans will feed you.
All in exchange for... rubbing your belly now and again.
That is an evolutionary jackpot.
And that’s as good an explanation as any, since cats are remarkably useless otherwise. A small, trained dog can hunt mice and rats more effectively, though there is some benefit to the relative autonomy of the cat when you consider the role of barn cats or ship’s cats. Cats living in close contact with humans definitely seem to benefit from those humans developing some hard-to-explain fondness for them. Yes, they’re so cute and fluffy and precious, I recognize that, but that’s exactly what I would say if I was infected by a brain parasite that wanted me to ensure the survival of its host.
Concrete example: Peacock tails
Which, ironically, also works out for them in another way--during the current Holocene extinction, for example, "convincing the humans to spare you from their rapacious reshaping of the entire planet" is quickly becoming a key evolutionary adaptation, which may very well end up saving otherwise completely useless animals like pandas or chickens, as well as other "charismatic megafauna" like lions. It may have already saved elephants--since antiquity, there have been a fair number of human cultures that venerate elephants for one reason or another, which is a pretty good evolutionary niche if you can get it.