As Chief Justice Marshall famously wrote in McCulloch v. Maryland, “[T]he power to tax involves the power to destroy.” When the state taxes something, people will seek to avoid the tax. Thus, the behaviors we tax tend to decline insofar as they are taxed.
Consider the taxes in the United States called the payroll tax and the income tax. Both of these are taxes on people getting jobs and going to work every day. Although they have good effects--they fund the government--one bad effect of these taxes is that they disincentivize work. This is a shame, because work is a social good.
Sin taxes are part of the solution to this problem. Sin taxes don't always tax actual sins in the theological sense--they often tax behaviors like cigarette-smoking that are bad for us, but not precisely in the way that a theologian might call sin. But the idea is similar. When a society taxes hard liquor or cigarettes, it is leading us to virtue at the same time as it raises revenue for itself. Prohibition of alcohol or cigarettes will lead only to black markets and black market crime. But by taxing drunkenness and smoking, we gradually lead people to virtue, while avoiding a utopian attempt to force people to be virtuous that would cause criminality.
Related to sin taxes are something called Pigovian taxes, named for the English economist Arthur Pigou. The idea behind Pigovian taxes is that the free market is not entirely efficient (as economists usually suppose it to be) because certain private actors' negative externalities are not priced in. An example of a negative externality is pollution. When a coal-powered factory pollutes the air, it is not paying for the bad effects (e.g., lung disease, global warming) that others suffer from its use of coal. Pigou's idea was that if we figured out how much that pollution (or some other negative externality) was costing everyone else, and taxed the polluter accordingly, then we would be restoring balance to the market. Once the factory owners had to pay for the costs to the rest of us of their pollution, they might choose to power their factory in some cleaner way. If not, at least they'd be paying us for the damage they were doing.
A sin tax goes beyond a Pigovian tax. It doesn't seek merely to have people internalize the negative externalities of heavy drinking or cigarette smoking, it seeks to punish them--through taxes--for their negative behavior in a way that will get them to stop doing it. A sin tax on pollution, for example, would go beyond the costs that the pollutant imposes on society to try to make polluting very expensive indeed. Part of the goal of such a tax, which I mention only as an example, would be to punish pollution as if it were in fact a kind of sin.
From a fiscal funding perspective, we finance our government with too many taxes on good things like going to work. Since we are going to have to have taxes of some kind, Pigovian taxes and sin taxes should be a bigger part of how we fund our government. Such taxes, if not set so high as to trigger black markets themselves, can also allow the state, where it is competent to do so, to lead us to virtue without promoting the black market criminality that comes with making vicious behaviors not merely expensive, but illegal.