Can someone explain how crystallization works to produce a product that is purer than the input material.

Thank you!

There is more than one factor.

First you hope that the impurities are more soluble than the major product so some of the impurity is lost in the dissolution step. Second, even if the solubility difference is not that great you lose some of the impurity at the same time impurity at the same time you lose some of the major product. You have MUCH MORE of the major product so the process of attrition helps get rid of some of the impurity. Next, you want to recrystallize slowly so the crystals have a chance to grow larger and larger. In what analytical chemists call "digestion" the exterior of the crystal redissolves and reprecipitates and in doing so the crystal tends to cleanse itself In that process the bonds for the crystal form at a slow pace and that tends to lock out impurities. (The opposite is true if you allows the crystals to grow fast. As the crystal forms impurities can get trapped in the crystal structure (what analytical chemists call occlusion or co-precipitation). The end process is a much cleaner and much purer major product with most of the impurities down the sink.