The modern bicycle chain is assembled out of a number of small parts pressed together with precision machinery. As you ride a bicycle the chain wears over time. This is referred to as “chain stretch” but it is a bit of a misnomer as the chain does not actually get longer. The pins, inner and outer links all stay the same length but the rollers and bushings wear down along with the cassette and chainrings. The recommended time to replace the chain is when these rollers and bushings have worn but not the chain and cassette. This way a new chain with fresh rollers and pins will still mate well with the old cassette and chainrings. The modern wide range 11/12 speed cassettes use chains so narrow that they wear out more quickly than the wider links of an chain for an 8 speed cassette. This makes proper chain maintenance and replacement essential for a well functioning bicycle.
Proper maintenance is going to have the biggest impact on the lifespan of your drivetrain. Too little lubrication and the excess friction and heat will wear out the chain faster that usual. Too much lubrication and the excess dirt and debris stuck to the chain will grind on the chain, cassette, and chainrings, wearing them out prematurely.
First you will need a drip bottle of your favorite lube and a clean rag (ripped up old t-shirts are perfect for this). Take the rag and place it on the ground underneath the chain, then shake your bottle of lube, open it, and hold it upside down above the lower half of the chain as you spin the pedals backwards 3 or so rotations until the entire length of chain has been coated. You don’t have to worry about applying too much lube on the chain because you will be removing the excess during the next step. You do want to put enough on to rinse away dirt and debris as well as allow it to penetrate between all of the plates and rollers on the chain. The goal is to get the lube inside the chain and then remove the excess from the outside of the chain.
After the lube has been applied you want to pick up the clean rag, fold it over, place it in the palm of your hand. You may want to put on disposable gloves or have a sink with some heavy duty hand cleaner nearby at this point. Wrap your hand and the rag around the lower half the chain and firmly squeeze as you rotate the pedals backwards. Pull up on and push down on the chain as you are spinning the cranks backwards to remove as much lube as you can. Move to a clean section of the rag every few rotations, when the rag only shows light grey (which may take 40-50 rotations) instead of black from the chain you know that the chain is cleaned, lubricated, and ready to ride!