You need new shocks (and/or struts) if your original shocks (or struts) are worn out, damaged or leaking. Leaking is easy enough to see (just look for oil or wetness on the outside of the shock or strut) as is damage (broken mount, badly dented housing, etc.
Shocks and struts do not require replacing at specific mileage intervals like filters or spark plugs, but they do wear out and eventually have to be replaced. How long a set of original equipment shocks will last is anybody's guess. Some original equipment shocks may be getting weak after only 30,000 or 40,000 miles. Struts usually last upwards of 50,000 or 60,000 miles.
But when exactly a shock or strut needs to be replaced is hard to say. Because the damping characteristics of shocks and struts deteriorate gradually over time, the decline in ride control often passes unnoticed. So by the time to think you need new shocks or struts, it's usually way past the point when they should have been replaced.
A "bounce test" is still a valid means of checking the dampening ability of shocks and struts. If the suspension continues to gyrate more than one or two times after rocking and releasing the bumper or body, your shocks or struts are showing their age and need to be replaced.
Why Replace Them?
Weak shocks and struts increase the distance it takes to stop a vehicle on a rough surface. Increased body sway due to weak shocks or struts can also increase the risk of skidding on wet or slick surfaces. Worn shocks and struts also increase suspension wear and can have an effect on tire wear.
The reason why most people decide to have worn shocks or struts replaced, however, is to improve overall ride quality. If you're sick of bouncing and rocking on rough roads, a new set of shocks or struts will firm up your suspension and restore proper ride control.
If you're interested in performance handling, you can upgrade to premium "gas" charged shocks or struts. These are charged with high pressure nitrogen gas to help minimize foaming in the hydraulic fluid inside the shock. This lessens "fade" on rough roads and helps the vehicle maintain better ride control when cornering.
There are also "heavy-duty" replacement shocks and struts that have larger diameter pistons than stock. These too, provide increases resistance for greater control -- but may be a little too harsh for everyday driving. So some shocks have special valving or adjustable valving that allows the amount of resistance to vary.
Another option to consider if you tow a trailer or haul extra cargo are overload or air-assist shocks. Overload shocks have a coil spring around them to increase the load carrying capacity of the suspension (these also tend to ride stiffer than standard replacement shocks). Air-assist shocks have an adjustable air bladder that acts like a spring to carry extra weight. With this type of shock, air can be added on an "as needed" basis when hauling extra weight.