Add a few drops of sodium hydroxide solution to blue copper(II) sulfate solution and a pale blue, jelly-like solid appears at once. Before mixing, the ions Cu2+, SO42−, Na+ and OH− were all dissolved and spread through the water. When Cu2+ meets OH−, they attract each other more strongly than water can pull them apart, so they lock together as solid copper(II) hydroxide: CuSO4(aq)+2NaOH(aq)→Cu(OH)2(s)+Na2SO4(aq). The Na+ and SO42− stay in solution.
Solubility rules predict which pairs lock together. Compounds of Na+, K+, NH4+ and nitrate always dissolve. Most chlorides dissolve, except those of silver and lead. Most sulfates dissolve, except those of barium and lead, and calcium sulfate dissolves only slightly. Most hydroxides and carbonates do not dissolve, apart from those of group 1 metals and ammonium. To predict a precipitate, swap partners and look up each new pair.
A solid in the beaker is not always a precipitation reaction. Stir too much table salt into cold water and some stays at the bottom, but that is undissolved salt: nothing new formed, and more water would dissolve it. A precipitation reaction makes a new insoluble compound from ions that started in two different solutions.
Think of it like this. A precipitation reaction is like a crowded party where two guests from different groups meet and grip hands so tightly that they sink to the floor together: that pair is the solid. Everyone else keeps mingling as spectators. The solubility rules are the guest list that says which pairs grip.
Core idea. When two ionic solutions mix, a precipitate forms only if one new cation-anion pair is insoluble. Solubility rules tell you which pair it is, and the other ions stay dissolved as spectators.