I've read that drinking river water is unsafe. Did people in the past drink water from the well exclusively or did they deal with diarrhea constantly?
It depends how far in the past you're looking. Post-agriculture but pre modern sanitation, yes diarrhoea is a major problem. Pre-agriculture, however would have been a different matter. The majority of pathogens in river water are derived either from agriculture (e.g. cryptosporidium, giardia) from large human populations (cholera) or rodents associated with human populations (leptospira). There would, therefore have been far fewer disease causing organisms in river water Pre-agriculture. Add to that the effect on the immune system of Post-agriculture diet and lifestyle and it would seem unlikely that the cleanliness of most river water would have been a major problem.
It very much depends on the river and location along that river. if there is a city upstream who is defecating into the river, you'd better not drink from that river. But drinking from the same river upstream of this city could be totally fine.
Disease transmitted through the faeces were very common in the the 19th century especially in cities that had no system of evacuation of wastes. Now, of course the prevalence of such diseases depends on the type of society and therefore on the era and location.
Generally speaking, it is always best to carry tap water (or bottled water) on you. If you have to drink from a river, be cautious, talk to local people, think of what could live upstream (people, cattle, ...) and always use a good filtration system before drinking from any river.