The english family finds Rikki-Tikki, nearly drowned and separated from his mongoose family by a flood. They take care of him, and he responds to their kindness as would any mongoose. The boy's mother is the first to put the reason for his loyalty into words.
I suppose he's so tame because we've been kind to him." "All mongooses are like that,''..."If Teddy doesn't pick him up by the tail, or try to put him in a cage, he'll run in and out of the house all day long.
After Rikki-Tikki kills the Karait the brown snake, he is made even more of a hero by the family. In actuality, of course, Rikki-Tikki was simply acting as any mongoose does when in the presence of a snake. The instinct to kill them (and eat them, too, when they're hungry) had nothing to do with loyalty and everything to do with the basic nature of any mongoose.
Teddy's mother picked him up from the dust and hugged him, crying that he had saved Teddy from death, and Teddy's father said that he was a providence
Rikki-Tikki-Tavi recognizes that the garden is a wonderful location for being curious and for hunting, the two activities that are the most enjoyable of all for any mongoose. He determines to make his home there and to protect the people who happen to live nearby because it is his instinct to kill snakes and to be curious about the doings around him.