Government has done a fair job of legislating that subset of morality that says "don't violate the rights of others" - for example, two out of three murders get solved. Government has an abysmal track record when it comes to preventing immorality conducted among consenting adults, and has done a great deal of harm in the attempt.
Murders getting solved is not the same as preventing murders. Two different data sets.