why do governments provide certain goods instead of leaving the provision of those goods to the free market?
Plenty of reasons.
1) the good could be a public good, like national defense. (look up the characteristics of a public good).
2) it could be a merit good, something that society, in general, believes everyone should have (food, housing or medical care).
3) it could be a good with strong positive externalities (e.g., basic education or public works of art),
4) it could be a good where it would be very difficult for a private firm to recover the good's development costs (e.g., basic medical research), or where the capital costs are too great for a private firm to handle (e.g., highways)
5) It could be a good we wouldnt want a private firm to exclusively provide (e.g., police protection or the criminal justice system).
6) the good could come primarily from a resource that we believe belongs to society in general (e.g., national parks
7) it could be something that governments have traditionally provided and we expect them to continue to provide (e.g., tours of the White House, or fireworks on 4th of july)