Snakes get such a bad rap. Honestly, they always have to be the bad guys or play animal totem for the villain. Voldemort's symbol is a snake (called Nagini—sound familiar?). Orochimaru uses snake-themed powers, Jafar changes into a snake, the chimera is one-third snake, and the list goes on and on. But do Nag and Nagaina deserve to get the typical bad-guy snake treatment? Yes and no. It kind of depends on how you read the story.
But let's be clear. These two will always be read as antagonists because they are in conflict with the story's protagonist, Rikki-tikki. What we're questioning here is more their characterization as villainous antagonists.
If you read the story in a classical sense, then yes, Nag and Nagaina are totally villains. Specifically, they represent the western archetype of the dragon. Just like the dragon is associated with the devil, Indian cobras are associated Hindu deities—which in Kipling's era would have been associated with evil, pagan gods (although, obviously, that's not the case today). Just like the dragon, these cobras are attempting to kill the pure, good, and virgin character (read: Teddy). So, they are obviously in conflict with the heroic knight, a.k.a. Rikki-tikki-tavi.
As such, the cobras are seen as a force of evil, through and through. They are described in evil terms, like Nag's arrival with a "low hiss—a horrid cold sound" and "wicked snake eyes" (23). Likewise, Nagaina makes a "savage hiss" when she misses her chance to kill Rikki-tikki (30). Oh, and they try to kill the British family with a sneak attack. Not Cool.
But if you read the story in a postcolonial light, the characters of Nag and Nagaina take on a less evil hue. First, we need to get a little deeper into the cobra's place in Indian culture.
Indian cobras are often depicted as having a very close representation with Hindu deities. Shiva has an Indian cobra curled around his neck, and while Shiva is a deity of destruction, he's also an agent of regeneration. (We should be mindful here that destruction in the Hindu religion is not seen as something permanent. It's just another cog in the continual cycle of death and resurrection, so destruction isn't viewed as such an evil force as it is in western mythology.)
The cobra god Shesh Nag also serves as the bed for the Hindi deity Vishnu (ooh, cozy.) And let's not forget the cobra's role as an important figure in many cultural stories and customs like snake charming.
If we take this cultural consideration into account, Nag and Nagaina become more symbols of Indian culture than the archetypal dragons of the classic reading. The story itself connects the two when Nag mentions, "'[t]he great god Brahm put his mark upon all our people when the first cobra spread his hood to keep the sun off Brahm as he slept'" (24). That makes one more link in the chain connecting the cobras to Indian culture.
And, from that perspective, the cobras are scary not just because they've got that nasty venom, but because they're not willing to give into the rule of the British family. The cobra's desire to be "king and queen" of the garden is simply their desire to rule a land they are native to (54). In a way, their battle against Rikki-tikki and the family is simply a battle to protect their way of life.
The foreign and evil side presented in Nag and Nagaina is specifically the point of view of an outsider, a colonizer who sees them as threatening (fair enough), out of the ordinary (apparently not), and foreign (definitely not). Would an Indian writer have written the same kind of story? We doubt it.