If that reason had anything to do with the law, it would be a fire code thing.
No, the real reason is a coalition between moral purity (left over from the temperance movement) and revenue protection. Ever heard of "Baptists and bootleggers"? Same thing, except the bootleggers are the government.