"He looks just like you" is a very diplomatic solution in such a situation. The doctor must comment on the child's appearance. The doctor can't say that the baby is ugly. It would be very rude. They don't want to lie either so they choose to say, "He looks just like you." It says nothing about the child's appearance unless you know what the doctor thinks about the way the mother looks. The mother is happy because every mother likes to hear her child is similar to her. The doctor is happy too because they didn't have to lie.
But we know what the doctor meant. They meant the mother was as ugly as her child. So we can laugh at the mother - because we know she didn't get it and is happy despite having been insulted. And we can laugh because the doctor's solution was so smart.
Student or Learner