They're vestigial structures (meaning they're "left over" from some ancestor species of the whale). In the whale's ancestor species, the pelvis and femur were functional; over time, as the whale started living in the ocean and they became unnecessary, the pelvis and femur shrunk into what they are now.