National Geographic Magazine did a wonderful
article recently on the evolution of whales and
addressed this exact question. See the November
2001 Issue, p. 64.
Basically, the article states that about 65
million years ago, the ancestor of the whales
walked on land and was related to the modern-day
horses and cows (a group of hoofed mammals called
ungulates). Recent molecular data has
indicated that the whales closest living relative
on land is the hippo! It's that surprising!
However, they think that hippos and whales began
diverging (evolving very differently from one
another) about 63 million years ago. A lot can
happen in 63 million years.
In addition to molecular evidence indicating
that whales evolved from land-dwelling ancestors,
go to your local museum and look at any whale
skeleton. You'll see two tiny sets of bones on
either side of the back bone near the rear of the
animal. These sets of bones are what is left of
the whale's hind legs and feet! These sets of
bones are called "vestigial hind limbs".