If fat and sugar are bad for you, why have we evolved liking them so much?
(Lansing State Journal, August 30, 1995)
Fats and sugars were hard to come by. People who had a taste for fats and sugars were probably more likely to take advantage of foods with fats and sugars in them, when they had the chance, than people who didn't. In other words, these people would take in more of these necessary but hard to find nutrients and therefore would be healthier and more likely to survive extreme conditions.
Thus, people who had a desire for fats and sugars were "naturally selected" to survive over those who didn't.
Even though this trait is more of a disadvantage today, most of the health problems it causes aren't seen until after people have reached an age where they have reproduced. Therefore, the trait isn't "naturally selected" out and still persists.