Beautiful topic. I will opine and use the word “thus” too often.
Tolkien's universe was implemented with an ordered plan by
Eru (by Tolkien). Just like
evil is goodness slightly skewed, ugliness is beauty slightly skewed. Anything that could have order is less beautiful than something which similarly has more order. Entropy leads to chaos at an atomic level, and thus “every fair from fair sometimes declines/ by chance or nature's changing course untrimmed.”
Entropy can be stopped or reversed in a thing, but only at the sacrifice of the environment around the thing;thus, something can appear beautiful which, if left to its doom (entropy), would otherwise age naturally. Also thus, things which are ugly can become beautiful, either by the ultimate creating force, who can change the nature of the thing itself into something beautiful, or by a sub-created force which, acting of its own accord, may choose to defy the doom of all things physical, namely, entropy, and screw up the environment around it (usually entropy is sped up around the where it is forcefully slowed down).
Beauty, in effect, is the perfect synchronization of a thing to its intended purpose or form, and thus, is the result and power of creators, sub-creators, and rebels: all things which can give order.
To kill implications, something can be ugly in the eyes of
men and
elves who may purport to see something through the perspective will of Eru, and therefore they see
orcs as ugly.
Beauty can be the result of an evil instrument defying the order of the original “composition” and creating its own music, so to speak. The resulting music may be beautiful, but disharmonious and out of order with the accompanying music. Beauty is captivating, and may pull other sound-makers out of the will of the great composer--and is seductive--like
Sauron with his temporarily rockin' bod.
Bad guys are ugly because they are the result of disharmony in the grand composition of music.
Because music tones can either be harmonious or not—and the representation of characters which are disharmonious due to
Melkor's unexpected “wicked solo” described in the Sil—Tolkien probably randomly chose to visually represent tonal harmony as beautiful, and cacophonous tonality as ugly.
Granted, Tolkien could have done the reverse. Or maybe he did?
Anyways, the short answer is: pure, arbitrary randomness.