In the climax of Jurassic World (2015), when the genetically modified dinosaur Indominus Rex kills all the raptors trained by the hero, Claire releases the T-Rex from the cage. It assists in defeating Indominus Rex.
The T-Rex is not trained like the raptors. Why did the T Rex help the protagonists, instead of just eating them?