Depth of discharge (how low you let charge level get before you charge it) has a profound effect on battery lifetime - if you can keep battery well charged it will last longer, every time the battery gets below about 60% charge it suffers cumulative permanent damage to battery chemistry. Keeping this level of charge isn't too hard if the car gets used every day for a decent journey (starting the engine takes less than 4% of capacity normally, unless you have to crank engine over for a long time). The normal run of the mill lead / antimony batteries last about 4 years normally. The newer lead / calcium and lead silver batteries are more expensive to buy but last a lot longer - get a good battery if you have an auto car (and some jump leads), remember you cannot 'bump' start an auto - its the battery or a jump start........
Due to better quality control and construction a modern battery will not normally fail catastrophically (they used to die suddenly and completely with very little notice when welded joints between cells failed)- they normally just gradually get 'tired' and slower to turn engine over as the battery ages and will no longer accept a charge as well as a new one, and don't want to release power as easily - in other words batteries lose their capacity as they age - and may drop from a a 40a/h when new to nearer 30 a/h, and the cranking amps (CCA) gets less as well.
A good and easy test is to put headlights on and watch them while someone else starts the car, with a new battery voltage may drop to about 9 volts under starting load and lights will go a bit dim, but when battery is on the way out voltage may drop to 6 volts or less under starting load and lights will go very dim. If lights do go very dim it may be a bad terminal post to battery cable lug connection, raise the bonnet and feel the terminals -- if one of them is very warm / hot the terminal to lug connection may need cleaning and a good dose of vaseline (it is normally the positive post that corrodes and gives problems, but even then modern batteries use better alloys in posts to stop corrosion).
Another thing to remember - most batteries today have a little round porthole in the top with a colour chart next to it, this is just a floating ball (a hydrometer) to measure specific gravity of acid, this ball is only looking at one cell to show 'general state of battery charge' - (all cells are sealed from each other) so it is possible one of the other 5 cells has a shorted plate or similar problem which will lower battery voltage and capacity while the ball colour is showing green or whatever to say battery is OK.