Solids that form during a reaction between chemicals in solution are called precipitates. Precipitation reactions can help isolate useful products; they also help researchers identify ions in solution in qualitative analysis. Consequently, it's very helpful to understand some of the factors that determine whether and in what quantities a precipitate will form.
Entropy is often described as a measure of disorder; a more accurate way to think about entropy, however, is in terms of the number of ways you can arrange all the molecules in a system that still exhibits the same total energy. The laws of thermodynamics dictate that spontaneous change always proceeds in the direction of increasing entropy; this is why heat never flows spontaneously from cold objects to hot ones -- only the other way around. The entropy of a system can only decrease if it takes in energy from outside, in other words, if an external process acts on it. When a reaction releases heat energy, it increases the temperature of its surroundings, which leads to an increase in total entropy.
Gibbs Free Energy
One of the most important equations in thermodynamics is the definition of Gibbs free energy: delta G = delta H - (T x delta S). At constant pressure, delta H is the amount of heat energy absorbed or released by a reaction; delta S is the change in the entropy of the system; and delta G is the change in the maximum work the system can do without expanding. Any process that has a negative delta G is spontaneous, whereas any process that has a positive delta G is not. Consequently, formation of a precipitate is spontaneous if delta G is negative.
Under what circumstances will delta G be negative for a precipitate formation? In most, though not all, cases, delta S will be negative for precipitate formation, because the solute in the liquid is more disordered than the solid precipitate. Consequently, we usually need a negative delta H to make precipitate formation favourable. Remember that when a chemical is dissolved in water, the molecules of that chemical are attracted to the water molecules. If the attraction between the solute molecules is much stronger than the attraction to the water molecules, energy will be released when solute molecules come together, which will give us a negative delta H. The strength of the interactions between the solute molecules and between solute and water molecules is thus a key factor affecting precipitation. Clearly, solubility for most compounds is also going to depend on temperature to some extent.
At any given moment, some molecules in a solution are coming together to form precipitate, while others are redissolving and being carried back off into the solution. At some point it will reach an equilibrium in which these two processes are happening at the same rate. This equilibrium is related to delta G by the following equation: delta G under standard conditions = -RT ln K, where R is a constant, T is temperature and K is the equilibrium constant (the ratio between products and reactants). The equilibrium constant for solubility of a substance is called the Ksp. Once you know the Ksp, you know what the ratio of precipitate to solute will be for a precipitation reaction.
Common Ion Effect
Ionic compounds dissociate when they dissolve in water; sodium chloride, for example, splits up into sodium ions and chloride ions, each surrounded by a shell of water molecules; when they precipitate they come back together. If you increase the concentration of one of these ions, you increase the amount of precipitate, because the Ksp is constant and has not changed. Consequently, if you add chloride ion to a solution of silver chloride, you would cause more silver chloride precipitate to form. The common-ion effect gives you a way to precipitate more of a substance that you want to remove from a solution.