On Tuesday, in settlement of a lawsuit brought by residents and public interest groups, Michigan agreed to spend $87 million in state and federal funds to undo that damage and replace about 18,000 pipes in the next three years.