Good road design accommodates pedestrians when pedestrians will be present (i.e., controlled-access freeways are designed with the assumption that pedestrians will not be present), but speed limits have very little to do with pedestrian safety.
Pedestrian safety is improved by design features of the road, and generally the design is based on the expected 85th-percentile speed of vehicle traffic.
A pedestrian hit at 20 mph is likely to sustain minor injuries. A pedestrian hit at 40 mph almost always dies.
Drivers also have much better road awareness and much more time to react at 20 mph, and pedestrians likewise have a better chance of jumping out of the way of a slower-moving car.
One good street design idea is narrowing traffic lanes. This makes drivers slower and more careful, but doesn’t cause any increase in accidents, and doesn’t substantially reduce car throughput. It also provides extra space that can be used for bike lanes, sidewalks, and better designed intersections.
Drivers are much more attentive when they're always looking all around for potential obstructions.
Speed limits are, in turn, influenced by the road's design.
As such, it makes sense to slow cars down to 20, even 15mph - the time loss (if there even is any, people driving in cities are just accelerating unnecessarily from light to light) very much makes up for the dramatic reduction in kinetic energy that endangers pedestrians and other road users.