Rikki is determined to destroy Nag and Nagaina because it is his instinct, and because they are threatening his people.
We are told that mongooses all want to be a house mongoose. I am sure it is a cushy job. A mongoose’s instinct and will in life is to kill snakes. It is part of protecting the house, and it also protects the mongoose.
When Nag and Nagaina see Rikki, they know they are in trouble. The cobra pair were doing pretty well before Rikki arrived. They laid a bunch of eggs and were seemingly safe, except for if the people saw them. Rikki’s arrival changed all of that. Rikki was an immediate and serious threat.
Nag was thinking to himself, and watching the least little movement in the grass behind Rikki-tikki. He knew that mongooses in the garden meant death sooner or later for him and his family, but he wanted to get Rikki-tikki off his guard.
Of course, Nag and Nagaina are not completely innocent. They eat birds’ eggs, and that is the same as murder to Darzee, his wife, and Rikki. Rikki eats eggs too, as Nag points out. It is the nature of the animal kingdom that everything eats everything smaller than it.
The snakes and mongoose pit themselves against one another, and the next thing you know it is a fight to the death. Nag and Nagaina threaten Rikki’s people, and he can’t tolerate that. His job is to protect the people.
They sat stone-still, and their faces were white. Nagaina was coiled up on the matting by Teddy's chair, within easy striking-distance of Teddy's bare leg, and she was swaying to and fro singing a song of triumph.
Rikki kills Nag, and then has to deal with Nagaina. She is dangerous, because she is wary of Rikki and has to defend her eggs. Rikki uses them to trick her. He hopes that she will be so overcome with grief when he destroys them that she will not be able to think straight.
Nagaina takes her last egg and flees into her hole, and Rikki has no choice but to follow. This shows real determination and courage, because she knows the hole much better than he does and it is dangerous to fight in a confined space. None of the animals expect him to win, but he emerges and Nagaina is dead.