I'm going to avoid taking offence at that -- and I'll try to answer.
Well, that's an interesting thing to notice. Maybe it's because most good looking people are confident and outgoing because of their outward appearance, that they then become popular over the ugly. The ugly then have to compensate.
Like, for example, me, I myself *am* considered ugly, and I get about an 88% average overall, if that counts as smart. I'm so "ugly" no one ever invites me to parties, and since I don't have a boyfriend or anything I therefore have more time to study? What a sad fact for a 15 year old girl to realize...
Could be, or maybe there's an assumption that if someone has nothing going on on the outside, that surely they must make up for their lack of outer flamboyance with intelligence. Of course there are a fair number of jocks who boast a 98% average, and a bunch of ugly people who are...stupid.
Also, the *stereotypical* smart people are shy and quiet people who dwell in the library...maybe they're so shy they are afraid to not do well, or they suffer from mental disorders (maybe every genius is considered "crazy") or maybe they have other things to worry about their appearance. Maybe an allegedly "ugly-smart" person's values are different from a better looking popular "stupid" person: that they care more for knowledge and academics more than fashion and parties.
I really don't know, every person is different, and has different reasons for the way they are...but it's an interesting stereotype you noticed. I hope this post was helpful.