Who taught you that dementia was a punishment? That's just.... delusional.
I'm still a nursing student, and not an expert by any means, but I've read a fair amount about dementia. I read that one way to prevent dementia symptoms is to use what you've learned and continue to learn new things. When the brain is constantly making new synaptic connections, it can prevent the confusion and memory loss associated with dementia. For example, someone who does crossword puzzles or learns how to use a computer is forced to recall information they've learned and use it in a new way. This causes another "route" or "highway" to be built or remain open in the brain (neuronal circuitry) which then helps the brain to avoid having areas that have fallen to disuse. Basically "use it or lose it" aka brain plasticity.
Now if someone has a low IQ, or they grew up impoverished during childhood and didn't get a good education, when they are older they are going to have less information to draw on for recall. They're not going to be able to apply things they've learned to new situations, because their knowledge database was lacking in the first place. Someone who was forced to go to work at a mundane or laborious job at a young age, and that's all they did their whole life, is going to be more likely to develop dementia because they stopped learning new things. Compare that to someone who had a higher IQ and came from a higher socioeconomic class - they went to college, traveled, perhaps sought out new experiences into their old age.
And then there are environmental factors as well. People with low IQ are more likely to use substances out of frustration, watch television instead of reading a book, eat food that is not of optimum nutrition, etc. I'm not saying that intelligent people don't also have these problems, but I don't think I'm wrong to assume the correlation between low IQ and poor choices regarding environmental factors. JMO, please don't rage at the sweeping generalizations I've just made :)