Regulations are the best way government can deal with negative externalizes, that is negative impact of the companies on third parties, such as on the government.
One example of such regulation is the regulation on the release of pollution from factories.