Yes, it the job of a government to do those things. The government whose job to do them is not our federal government but our state and local governments.
It wasn't UNTIL a very few decades ago when anti-discrimation laws were passed that restaurants, hotels, gas stations, even restroom facilities were finally and YES FORCIBLY desegregated, that "the environment" got largely cleared of the kind of outright DANGERS to black motorists.
IT BECAME A SERIOUS CRIME to deny goods and services to people based on race, creed or color.
That is what it took to finally clear the logjam.
All the competitive pressure in the world was unable to stop a bunch of rednecks with shotguns, bullwhips, ropes and even MURIATIC ACID from exercising Jim Crow laws and "Sunset Town" warnings.
So it finally fell to the Federal Government to do the heavy lifting when states failed to do it for themselves.
The general welfare does not share your rather extreme anti-government bias.