Okay but what you need to understand is that the EPA's allowable level of lead for municipal water supplies is 15 parts per billion (PPB) (which is very low), and the standard doesn't change based on what materials were used for the pipes. Getting below that threshold is not only achievable but expected even with lead pipes, if you treat the water properly. Flint's problem was that it didn't, because the Governor kicked out the people who knew what the fuck they were doing!
As for your 20/20 hindsight, it's just that: hindsight. A lot of these pipes date back to the early 1900s or earlier, when not only had plastic not yet been invented, even copper pipe barely existed because they hadn't figured out how to efficiently manufacture it water-tight yet (source). That means the alternatives to lead pipes were really shitty, such as terracotta or wood, and even if they did manage to use early copper pipes or some other metal, guess what: the joints would all be soldered with lead anyway. Moreover, this was also back when they were so ignorant about the cumulative effects of exposure to lead that they still thought it was a good idea to put it in things like gasoline and paint, so why would they have concerned themselves with the relatively small risk from using it in plumbing?
If Flint were a sunbelt city built mostly after 1950, then sure, using lead for the pipes would've been inexcusable. But Flint was already in decline by then, so most of it is older than that!