The most important thing about law is that the law does not define human rights. The law may attempt to enforce your rights or it may violate your rights, but your human rights exist irrespective of what is, or isn't, law.
Laws are enacted and enforced by government - by politicians. Clearly they will choose laws which they judge are most likely to give them wealth and power. When it suits the politician, the laws will enforce people's rights - law and order makes for good political rhetoric. Equally, when it suits the politician, the laws will violate people's rights - taxation revenue is a handy way to buy votes, and the need to wage a war-on-X makes good political rhetoric too.
Generally, governments ban actions which would lower their tax revenue, and these rules are enshrined as law.
Fortunately Western governments have realized in the latter part of the 20th century that more taxes can be raised from a society which is relatively free, so people in the West live reasonably well.
Generally these rules are enforced by the police, breaking these rules is regarded as a crime, and punishments are decided by the judiciary and may involve paying a fine, being sent to prison, tortured or executed.
In democracies the law is slightly closer to people's notion of natural law, but not much.
See