The simple and unsatisfying answer is traffic engineers doing traffic analyses.
A bit more in-depth answer is that roads are broadly divided into highways, arterials, collectors, and streets. Highways connect cities. Arterials are the major routes within cities. Collectors are branch or minor streets but not residential. Streets are your typical residential street. Roads can change categories as they go along.
Most of the road sizes are determined when the city is/was planned with smaller roads branching from larger ones down to residential streets. Engineers determine the traffic loading either by measuring existing traffic amounts or by estimating loading from city use maps (this is large part of what your city planning department does).
Once they have a model of traffic loads on each road they assign a speed limit or adjust the size/loading of the road. This gets reviewed by a number of city departments who ask questions, clarifications and/or for adjustments. Once all departments have been satisfied the city instructs the Public Works department to install the speed limit signs accordingly.
