Azolet has to be right, if you believe in God. If you don't, you can argue that genetic variability, which includes all the different variables of human appearance, is just how evolution works. (Me, I think a lot of the anomalies in the universe, including what we humans see as 'bad' stuff - which may only be bad from our species' point of view; an influenza epidemic is great for the 'flu virus even if it kills a bunch of us! - are easily accounted for from a spiritual point of view if you accept that there's no logical reason for any creator deity to have been 'perfect'. Maybe s/he is doing the best they can, who knows?)
As for 'ugliness', from a human, moral viewpoint, it does help you weed out the a-holes. If someone makes themselves out to be nice, liberal, accepting of racial and sexual and all other variations, but treats another human being like crud because they don't come up to their fine esthetic sensibilities...you know a little more about what they're really like. Not that that has anything to do with the actual question of why are there 'ugly' people, but it's one knock-on effect of it. Animals will reject and sometimes kill a member of the pack who doesn't look like the others; we, as humans with the power of reason, are worth more than that.
Anyway, as the great Spike Milligan said:
Beauty is in the eye of the beholder. Get it out with Optrex.
Even the most superficial glance at humanity, now and throughout history, can see that reason is not the most powerful influence on the species and our worth varies with what our values may be. Reason obviously is not held in high regard by a large sector even at this site.