Laws are very frequently downright immoral. They are immoral simply because they are an attempt by one group to regulate the behavior of another when no concievable harm can be done to the legislating group by the "immoral behavior" of the "offending" group.
For instance the legal penalties for recreational drug use. They are justified by assuming the use of recreational drugs leads to crime and other antisocial actions.
By making drugs illegal we (society) raise the price thus subsidizing the purveyers of such drugs making it much more worthwhile to violate other laws and encourage new customers. The drug battles in our cities and the destabilization of Colombia are but a few of the results of such "immoral" laws.
By making prostitution illegal it precludes any attempt to regulate the practice thus magnifying the (real) health risks to society as a whole. A licensed prostitute could easily be subject to the type of inspections that our food sellers, resturant operaters ande meat packers are subject to. With prostitution illegal there is no hope of ever regulating it for the protection of the general public or for the prostitutes and their clients.
Thus I conclude that an "immoral law" usually makes the problem worse that it would be if there were no such law at all. This is what makes it "immoral"