Why does 925 sterling silver jewelry tarnish, and how do you prevent it?

Sterling silver will tarnish because it contains Copper (Cu), added to give hardness and solidity to the silver, it is the copper that tarnishes.
“Pure” silver 99,99% (Ag) contains so little copper it will not tarnish, but as the other hand is far to soft to retain shape if used in jewellery.
Nowadays it is possible to acquire varieties of 925 silver that does not tarnish, the best known is probably Argentium.
This alloy replace some of the copper in the classical sterling silver alloy with Germanium.
Another popular way of preventing tarnish is to give the finished piece a fine coating of either fine silver or Rhodium.
Silver tarnishes because the chemical composition is affected by the air which causes a reaction turning the silver black. Some factories solder their jewelry in an oxygen free environment to reduce this during the manufacture of the jewelry but it still needs to be filed, brillant, and plated in the end. There is a procedure called E-coating which is like a varnish for better way of explaining it that keeps the jewelry from being exposed to the air by creating a barrier. Eventually the E-coating will wear off and the silver will tarnish. It is best to store your jewelry in a cool dark place and gently wipe it off after wearing it to keep the tarnishing to a minimum, but eventually all silver will tarnish. That is why Gold jewelry does not tarnish, its composition is not affected by the air which we breath.