That statement is usually finished, "...a law." It refers to something that's going on that the speaker thinks shouldn't be going on, and so he or she suggests a legal remedy for the problem.
In the classic Schoolhouse Rock episode "I'm Just a Bill," the initiating incident was a person watching school buses zip across railroad crossings without stopping and thinking that was a dangerous enough practice that a law should be passed requiring bus drivers to stop their vehicles at railroad crossings and then proceed.
Most of the time, "There oughtta be a law" isn't actually true. There may already be a law that covers the issue, the way that statutes prohibit careless and inattentive driving and make sort of redundant measures to ban texting while driving. Or any law that prevents the observed errors would create more problems than it solves, or conflict with an existing law or constitutional provision.
However, this recent case in Louisiana illustrates one of the times in which "There oughtta be a law" makes perfect sense. We have yet another incident in which people armed with legal authority but lacking the sense God gave a bottle fly wrote tickets to Louisiana youngsters operating lemonade stands without the proper "occupational licenses."
The Louisiana state legislature introduced and unanimously passed a law that exempts business run by minors which make less than $500 per year from needing such licensing. "Unanimous" because there are some things even a legislator can figure out not to do.
So in this instance, indeed, there oughtta be a law. If Lousiana's code enforcement officials are going to try to operate without any sense of shame, well, then I guess a law's the only answer. But the bill authors had better use really small words. The people it's aimed at probably would have trouble with anything over five or six letters and two syllables.