Teeth first evolved in a common fish ancestor of reptiles, dinosaurs, and mammals.
The earliest direct evidence we currently have for true teeth comes from a tiny jawed fish called Qianodus duplicis, which lived about 439 million years ago during the Silurian Period. This tiny fossilized tooth whorls from China, how rows of teeth added as the animal grew.
But teeth almost certainly have an older backstory going back another 20 million years, in jawless vertebrates such as Eriptychius. These animals had dentine-bearing structures called odontodes on the outside of their bodies. Remarkably, modern sharks, rays, and skates still carry thousands of these tooth-like dermal denticles across their skin. Current evidence suggests that teeth evolved when this ancient developmental machinery was recruited into the mouth.
From there, teeth exploded into variety. Fish evolved rows, whorls, crushing plates, needles, and replaceable teeth. As vertebrates moved onto land, reptiles and the synapsid line leading to mammals kept modifying them. Dinosaurs took teeth in their own spectacular directions. Meat-eating theropods generally evolved sharp, recurved, serrated teeth for gripping and slicing flesh, while plant-eating dinosaurs evolved a much wider variety capable of grinding tough vegetation. Some dinosaurs even evolved distinctly different kinds of teeth in the same mouth.
In our own lineage, therapsids differentiated them into incisors, canines, and grinding cheek teeth. And evolution sometimes went the other direction. Modern birds descended from toothed dinosaurs but lost their teeth. Adult platypuses lost theirs too. Some fish even lose oral teeth while keeping teeth deeper in the throat. Once evolution had successful teeth, it was perfectly willing to reshape them, move them, or throw them away.