Homer's stupidity is often played for laughs, which makes sense. Who doesn't love a good oaf blundering from one bad situation to another? But in "HOMR," a parody of Flowers for Algernon, Homer finds out that the reason he's so stupid is because he essentially has brain damage.
When Homer was a child, he put 16 crayons up his nose, but one of them remained jammed in his brain, giving him the low IQ and poor impulse control that audiences love. (We suppose it's lucky that Homer's only as stupid as he is, considering he put that many crayons up his nose, but we digress.) Homer gets the crayon removed and finds he's able to better bond with his smart daughter, Lisa, and even improve his work at the nuclear power plant. This leads to massive layoffs when he diagnoses problems in the workplace. His friends begin to hate the new, intelligent Homer. He ends up getting the crayon replaced by Moe (who's a physician for some reason here) in order to return to his blissful ignorance.
In sum, Homer's life is basically ruined by his surprising intelligence, all to the point that he would rather willingly endure permanent brain damage than live his life as a smart person. Add to this that Moe's an apparent "unlicensed surgeon" whose life is so dour his suicide attempts have been played for laughs, and The Simpsons ends up with a pretty pessimistic view of the correlation between happiness and intelligence.