Like blue eyes, just consider it a random mutation. It has no evolutionary benefit, there is no rhyme or reason. A random group of genes mutated, and the result was the horseshoe. There must have been a population bottleneck at some point for it to be so prevalent... Actually the baldness gene is present in apes too, so the bottle neck must have happened to them rather than us, to be so common in human populations and ape populations. Most apes and humans bread at younger ages, before male pattern baldness kicked in, so the ugliness thing never got to be a factor until now. Also most breeding was done by rape or by instinct, not dating, romance, physical attraction or mutually consenting sex.
To understand why it is the shape that it is, if there is any reason, you'd best look at apes, not humans. Didn't start with us.
Like all of natures **** ups, it's just random, and like all persistent **** ups, it stick around because it doesn't kick in until later in life. A disease that doesn't kick in until several years after sexual maturity is essentially shielded from natural selection in evolutionary history