We've been keeping pets as a species for considerably longer than we've had cities. It's basically an ingrained part of how we react to animals now.
Beyond that, longer than we've had the written word.
Domestication of animals might be the single greatest achievement of humans.
In dwarf fortress you can have dragons as pets. Never got there, tho I think I will train dogs in my current fortress.