Actually, most of our written laws have become law because someone at some point either completed or attempted an act that society did not agree with. There was not a law against drugs until people started abusing drugs. There is really no way to officially enact every law that will need to be enacted and that is why we have a legal process. Because law is a process and it started with common law.
You see, society naturally has a popular idea of what is wrong and right. In the beginning of civilization, colonies and towns governed based on local traditions, customs, and rules. These were not written or officially passed laws; they were common laws.
When a case is decided based upon the result of a past case, or precedent, than it was decided by common law. This is the same case when a judge or jury has made a decision in one case that determines the results of future cases. Lawyers who cannot find an official rule that helps their case, they may site similar cases where the judge decided the way they want them to in their case. Of course, common law is trumped by written laws.
There are also common laws that are based upon tradition. One of these examples used to be common law marriage. It used to be the case that when men and women lived together as a couple, they intended themselves to be married. Today, men and women living together without intending to be married or ever get married is common. This means that tradition has changed and so has the common law governing this tradition.