Several of the other answers here talk about speed, energy and braking distance. But that's not what the question asked.
The question asked whether it is safer to drive at the speed limit, and makes reference to other cars driving both faster, and slower than this figure.
The answer to this is that there's no objective answer. Speed limits are a legal construct, and have no intrinsic relation to physics or engineering.
By far the biggest factors in road safety are:
- Paying due care and attention to those around you, and being alert
for potential hazards, while taking mitigating action to avoid them,
- Driving at an appropriate speed for the conditions at the
The appropriate speed depends on many factors, for example the density of the traffic; whether that section of road is straight and clear (or narrow and winding); presence of junctions; presence of parked cars; weather (snow, ice, fog, rain, or a clear dry day); driver experience; driver reaction times; and braking ability of the car.
This is not an exhaustive list. However it illustrates the complex factors which will come into any conceivable equation when calculating "What is the safest speed". Clearly, this is a question which can not be answered objectively.
With regards legal speed limits, you tend to find the same speed limit applied to the same road - regardless of whether one section is straight and clear, but another section has many junctions, or is a common place for cars to park at the side. Furthermore, most speed limits don't change on a daily basis according to the weather. This is why on a clear, dry day many legal limits feel absurdly low - whereas in snow and ice, on the same stretch of road the legal limit may be dangerously fast.
Part 2 of the questions asks whether it's safer to drive at the legal speed limit even when the prevailing speed of traffic is faster. Again, the answer is: "it depends". If the prevailing speed of the traffic is excessive, and the traffic is so dense that stopping distances are compromised (i.e it's actually an unsafe speed), then it would indeed be safer to reduce your speed to increase the distance between your car and the one in front (even at the expense of the annoyance of drivers behind you.
On the other hand, if the density of traffic is relatively light and there is plenty of stopping distance, then it's safer to go with the flow. The reason for this is because if you're driving significantly slower than the rest of the vehicles around you, you're causing them to swerve around you; change lane; and otherwise alter their behaviour by making them take additional manœuvres. At high speed, this can create more inherent danger than simply factoring in the energy calculation.
To recap: overall, higher speeds involve more energy, and therefore a reduction in the overall energy on the roads means that in the event of an accident, there is less chance of damage and loss of life. However this is unrelated to the "legal speed limit"; and there are many other important factors to road safety. Drivers who spend their time with their eyes fixed on the speedometer are generally paying less attention to the road around them.