Back in the long ago, rules of traffic as we think of them today didn’t really exist. You don’t see traffic cops in western movies. Horses and buggies went where they wanted, when they wanted. In the biggest cities, traffic sometimes clogged, but horses were pretty maneuverable and speeds were extremely low.
That first changed when trolley cars got introduced. Not the horse-drawn trolleys, but first cable-drawn ones (hence the epithet “traction barons” which puzzled the heck of me in school) and then electric ones starting in the 1890s. These were much faster, much harder to slow down, and not steerable off their tracks (or overhead wires). People died because they treated them like horses which would just get out of the way. The Brooklyn Dodgers got the name Brooklyn Trolley Dodgers all the way back in 1895; that was a joke that was no joke.
Automobiles obviously got introduced around the same time. They kept getting faster and more numerous and went wherever they felt like instead of staying on obvious tracks. More people died. Really, lots of people. Survivors got fed up and started screaming for safety measures. Traffic lights and then stop signs (again, really, in that order) were the rage in the nineteen teens, making tens of thousands of corner traffic cops unemployed, in an interesting and mostly unknown early incident of technological obsolescence.
Cities then started passing laws regulating pedestrians as well. Jaywalking, even as a term, was a thing unknown in the 19th century. Etymology places it in the early 20th. Pedestrian crosswalks appeared and police started ticketing people for walking across streets in the middle of a block, a development that would have baffled earlier cultures. The flip side of that was that if pedestrians crossed where cities prominently designated “only here” crosswalks, they needed some legal protection. Hence, pedestrians got the legal right of way.
That’s not an all-powerful amulet. Drivers still drove over pedestrians even on crosswalks. “Look both ways” is plain common sense. But people on foot don’t have more plain common sense than people behind the wheel. So a legal structure was created to assign guilt, making a driver hitting a pedestrian in a crosswalk automatically at fault, just as running into the back of someone else’s car is automatically presumed to be your fault. Right of way elsewhere than designated crossings is probably defined city-by-city.
Only took a few decades and many thousands of deaths, but as Churchill said, Americans always do the right thing, after trying everything else.