In "Muscle Claws", it is revealed that Plankton had gone back in time, brought the T-Rex back home, and kept him as a pet.