They
started off otter-sized and a little short on the majesty-o-meter. Little wolf-like critters who found the game by the beach the best eating. Eventually the big 'uns would survive and the dainty ones couldn't compete.
So whales, apparently, at one point were like these alligatroidish mammels haunting the shallows for protopoodles to devour...
As time progressed and chow became harder to find along the shallows, those better at swimming further out for dindin got the chance to eat, to sleep, perchance to breed...
Of course if you're really out deep, legs become a nuisense and good lungs keep you well fed.
Or as this helpful chart shows us...
the hind legs whithered* and the forelegs got finny. And so the whales become the Kings of the Sea...
While Charles became the Prince of Wales.
*
They didn't actually whither so much as those with smaller hind legs proved more adept at swimming, eating, and getting nookie.