It is supposed that over 50 million years ago some type of Mesonychidea, sort of a cat, or rodent-like animal, began spending more time in the water, hunting for food, and eventually began to adapt back to the water.
The return to the water may have brought significant benefits to these terrestrial carnivores. The animals in the sea were a new, and unexploited food resource. Nevertheless, it was millions of years before ceatceans appeared on the scene.
The earliest cetaceans were probably the Protocetidea, some 45-50 million years ago. All we really know about them was they had a few recognizable cetacean features, such as inflated earbones, probably for underwater hearing, and an elongated snout with nostrils near the tip. Some of them appeared to have retained hind limbs, and their lifestyle may have been amphibious rather than fully aquatic. Very few remains have been found, and they were probably less than 10 feet long.
By about 40 million years ago, there was the Dorudontinae. They were similar to dolphins, and grew to length of 16 ft or so. Their nostrils were still on the snout, but further back than Protocetidae, and their bodies more streamlined.
Between 24 and 34 million years ago, the two groups Odontoceti and Mysticeti arose. Among the many primitive Odontoceti, the Squalodontae was closest to modern dolphins, and is probablythe group from which most later odontocetes ultimately derived. These ceteceans were 10 ft or more in length, but still retained one primitive feature: that of heterodont dentition (ie: they had more than one kind of tooth. Modern dolphins have homodont dentition, meaning all their teeth are essentially alike.)
About 24 million years ago, a relatively diverse family known as Kentriodontidae appeared in both the Atlantic and Pacific oceans. They were about 6 feet or less in length. It is believed that the modern superfamily Dephinoidea (which includes almost all toothed whales, including dolphins), arose from this family about 10 million years ago.