Rikki-tikki is a mongoose, an animal similar to a weasel with a reputation for being a particularly effective enemy of snakes. Rikki-tikki is washed out of his home by a flood, and arrives half-drowned in the garden of a British family, who essentially adopt him (although Rikki-tikki, arguably, adopts them as well), particularly their young son, Teddy. Teddy's mother is nervous about allowing Rikki-tikki, a wild animal, into such close confidence with their child, but Teddy's father insists that having a mongoose around the house is better than having a dog.
Rikki's primary enemies are Nag and Nagaina, a pair of cobras. Karait is a smaller, but equally deadly snake, and Rikki's fight with Karait allows Rikki to be established as a successful snake-hunter, and therefore a hero, without encountering the main antagonists. From a literary perspective this amplifies the tensions and sets up their rivalry for a greater final conflict. From the perspective of the plot, Rikki's fight with Karait allows him to demonstrate his protective nature, and assure Teddy's mother that he is a benefit rather than a threat.