It allows viewers to experience the "social horror" of being backstabbed without real-world consequences.
Even more benignly, think of the "booktok" betrayals. When an author (say, a popular romantasy writer) releases a third book that kills a fan-favorite character or pairs a different couple, the internet erupts. Fans cry betrayal. They return physical books to stores. They write sizzling one-star reviews. This anger is free marketing. Publishers have realized that a book that creates polarized feelings—a sense of broken trust—outsells a nice, predictable sequel 10-to-1.
Motivated by survival, systemic pressure, or a "greater good." The traitor is easily unmasked and universally hated.