Inverse Solubility

For most solids that dissolve in water, the warmer the water, the more you can dissolve. That’s “most”, but not all. Some soluble molecules, such as calcium acetate, exhibit “inverse solubility”—the warmer the water, the less you can dissolve, and if you heat a saturated solution, solid will crystallise out. Why is this, and why are most gases, unlike solids, less soluble in hot than cold water?