It’s kind of strange to think that early humans would throw some of their hard-earned food to animals that were lurking around. Did they do it out of kindness or did they perceive that they might be able to tame them and put them to work?
It is known that soon after domestication, dogs evolved the ability to digest starch rich foods. In other words to subsist on human food waste. This is one of the things which sets them apart from their carnivorous wolf cousins.
This is a really interesting aside, because it turns out that until the 60s nobody had actually bothered to take the time to actually measure how much time hunter gatherers spent hunting and gathering. The answer was "not much", usually around 15 hours a week! [1]
This led to the 'original affluent society' paper. [2] The objections to it are quite asinine - like that cooking, cleaning, and other such time was not calculated, but of course such things also aren't counted for modern workers in their hours worked per week. Another objection being high infant mortality which again also applied, until quite recently, to industrial societies as well. It's an apples to apples comparison.
The point of this is that people in the distant past had rather extensive amounts of free time. And so them taking in some pets for fun and entertainment seems highly likely.
[1] - https://www.rewild.com/in-depth/leisure.html (in spite of the site's name this is an overview of academic literature on the topic)
[2] - https://en.wikipedia.org/wiki/Original_affluent_society
Humans have always left edible garbage behind.
[dead]
Mammals have a strong nurturing instinct, which helps with raising progeny. (So do birds.) Strong enough that it can overflow to members of another species. No calculation or ethical predisposition required, though they would strengthen the resolve.