The solubility of a salt in water depends upon their
(i) lattice energy and hydration energy.
In the case of hydroxide and carbonates of sodium and potassium their hydration energy is more than their lattice energy. Therefore, they dissolve in water. In the case of hydroxides and carbonates of magnesium and calcium their hydration energy is less than their lattice energy. Therefore, they are sparingly soluble