TL:DR: The Tyrannosaurus Rex’s closest living relative aren’t reptiles, but rather are chickens and ostriches.
We tend to think of dinosaurs as these large reptilian-like creatures because that’s what we learned in school and how they’ve been portrayed in movies. Contrary to this view, however, over the past few decades scientists are learning that dinosaurs are not as reptilian as we thought.
A series of fossil finds in the 1990s in China showed that some dinosaurs had feathers. Later discoveries suggest that the common ancestor of all dinosaurs had feathers and it is likely that all dinosaurs had feathers. Source.
In 2007, a chance discovery led to molecular testing that uncovered that dinosaurs’ closest relatives are birds and not reptiles. How this happened is an interesting story. In 2000 in paleontologists discovered a fossilized T. Rex skeleton in Montana and spent three years excavating it. Dinosaur skeletons are precious and treated with great care but the large leg bone of the skeleton couldn’t fit in the helicopter the paleontologists had procured to transport the skeleton. So, they broke the leg bone in half which also resulted in some smaller fragments of the bone. The scientists discovered un-fossilized soft tissue in one of the bone fragments and were thus able to run tests on proteins extracted from the tissue. They compared the protein to various modern animals, and found birds — specifically chickens and ostriches — to be the T. Rex’s closest relatives.
This story sheds some insight on the randomness of how some discoveries happen: serendipity is often a necessary ingredient of discovery. You usually don’t break apart dinosaur bones – unless they don’t fit in your helicopter! The Smithsonian Magazine summarized: “If they’d had a larger helicopter, we might never have known.”
According to paleontologist Stephen Brusatte of the University of Edinburgh, it makes some sense that the T. Rex and chickens are related. “When you look at a Tyrannosaurus rex and a chicken side-by-side, you can see the similarities. Both walk on two legs, both have scaly feet with sharp claws, and both have a big, brainy head perched at the end of a long, arched neck. Tyrannosaurs even had feathers, a bird-like lung which efficiently takes in oxygen during both inhalation and exhalation, and avian-like fast metabolism and stupendously fast growth rates.”