Precipitation occurs when the ionic product (Qsp) of the ions in solution exceeds the solubility product constant (Ksp). Adding $AgNO_3$ to NaCl solution increases the concentration of $Ag^+$ and $Cl^-$ ions, making their ionic product greater than the Ksp of AgCl.