Why do some solid chemicals dissolve better in colder water?
As with every process, dissolving can be described by the thermodynamical equation:

$$\Delta G = \Delta H - T \Delta S$$

Which the process being spontaneous if $\Delta G$ is negative.

We have two components here, enthalpic and entropic. The enthalpic component $\Delta H$ is a constant of the salt in question. The entropic component $\Delta S$ can usually be considered positive because a highly ordered crystal lattice is broken to give dissolved, much less ordered fragments — hence why for most salts they dissolve easier in hot water.

If the solubility decreases with higher temperatures, then $\Delta S$ must be negative. The salt will then only dissolve if $\Delta H$ is negative enough to give an overall negative result. This seems to be the case for $\ce{Na2SO4}$

It is impossible to predict $\Delta S$ and $\Delta H$ a priori without any computer quantum calculations. One has to resort to experiments to determine whether a salt will dissolve better or worse in the heat.



While I have used the term ‘salt’ most of the time, the same is true for molecules. Take sucrose: I was asked in a physical chemistry lab to guess with my colleague whether sugar would dissolve endothermicly or exothermicly. We decided, that the degree of order be a lot higher in dissolved sugar due to a high amount of water surrounding it rather tightly, that the entropy must decrease, so that the enthalpy has to be negative and sugar has to dissolve exothermically. Hence sugar should dissolve more easily in cold water, too.

According to a comment by Nicolau Saker Neto, our reasoning was false and sucrose displays increasing solubility at higher temperatures. Apparantly the testing faculty member approved of it, though.