Reactions in chemistry fall into many different categories. The "double replacement reaction" is a very common type that takes place when two pairs of charged particles essentially "change partners." Silver nitrate and sodium chloride readily undergo double displacement in water, producing silver chloride and sodium nitrate salt.
Video of the Day
Silver nitrate is an ionic compound, or salt, with the formula AgNO3. The silver nitrate salt consists of silver cations, positively charged particles, paired with nitrate anions, where an anion is a negatively charged particle. Collectively, cations and anions are referred to as ions, and any compound consisting of cations paired with anions is an ionic compound, or a salt. All nitrate salts are soluble in water, regardless of the cation, so silver nitrate dissolves well in water.
Like silver nitrate, sodium chloride is an ionic compound. The cation is sodium, and the anion is chloride, such that the compound has the formula NaCl. All sodium salts are soluble in water, so sodium chloride dissolves readily. It's critical that both sodium chloride and silver nitrate dissolve in water, because they're both solids, which would prevent them from reacting with each other via double displacement if they weren't water-soluble.
When silver nitrate and sodium chloride dissolve in water, the silver cations separate from the nitrate anions, and the sodium cations separate from the chloride anions. This occurs with all ionic compounds when they dissolve in water, and is called dissociation. Once the ions have dissociated from one another, they're free to move independently through the water and have the opportunity to react with other ions that are present.
When silver cations encounter chloride anions, they form the silver chloride, or AgCl, ionic salt. Unlike silver nitrate and sodium chloride, silver chloride isn't water-soluble. As soon as it forms, it "precipitates," or drops out of solution. The result of mixing silver nitrate and sodium chloride is immediate formation of a white solid that settles to the bottom of the beaker or reaction vessel -- this is AgCl. Sodium nitrate, which is water-soluble, remains behind in the beaker.