Evolutionarily, it'd be the other way around.
If members of a high caste are guaranteed wealth and many children, then there is no selective pressure for intelligence.
Likewise, if lower caste members struggle to survive, then there is a strong selective pressure for intelligence and problem solving.