Travel is coming in contact to other cultures and that means respecting how other cultures work and behave accordingly while visiting it. Behaving accordingly is not identical to obey the law and there are many reasons for this:
The law was written down a long time ago and still valid because the legal body does not retract laws, but is completely unenforced.
The US states have many laws that are cited by web sites as funny legal oddities, the problem is that most of these laws are simply not respected or enforced anymore. Only by knowing how natives handle these cases can the traveller come to a decision if and when these laws are enforced. In Germany the §166 literally taken prohibits the wearing of a fish skeleton T-Shirt because it could offend the Christian belief. In reality the law is almost completely ignored, the cases in 50 years could be counted at one hand. I think other people can cite many examples from their countries.
The law is so complicated, fuzzy and twistable that almost everyone violates the law..
Many, many examples: The US import laws. Germany's "hacker" laws. The Law against insulting the Turkish State. Spying laws in many countries. If you take the law literally, you are guilty.
In fact, the exact meaning and applicability of such laws are defined by courts. If it does influence the society, you will be informed as traveller. If it does not, it is no concern for you.
The law is ignored largely because it has no holding in the society.
There are many reasons for this. Some countries (Abkhazia) or regions (ISIS) are de-facto independent of the country they are nominally belonging to. Some laws were implemented by colonial bodies and clash completely with local law. The law is only given lip service (The human rights are almost universally acknowledged and also universally violated).
The law is ignored because it handles a very frequent case and the punishment is neglible.
Sleeping in a tent in the woods, bathing in a lake/river or crossing the streets with a red light is prohibited in many countries, but there is no real punishment if you are caught. They are mostly "Cover your ass" laws, so if you are injured by a fallen branch or you cut your foot in a lake or you are hit by a car you are guilty and you cannot blame anyone else.
Obeyeing the law is actually dangerous and it is continually violated for common sense.
I do not know if it still the case but the law demanded some time ago that if you want to drive on the autobahn and you cannot filter into the flow of the traffic, you should stop. In reality this law was always violated because the high speeds would guarantee that following cars cause rear collisions and therefore it was always violated. If you travel in a third-world country and a corrupt policeman charges you with a crime and expects a bribe, denying the bribe because it violates the law could end your life. Some punishments are draconic and even moderate prisons could kill you easily because of catastrophic conditions. We had a question here where you find hidden drugs in your luggage. The lawful solution is declare that you found drugs in your luggage and risking punishment. The common sense solution is getting rid of the drugs in a toilet and leave the country ASAP.
For all this reasons I think no, our guideline should be that we give advice which gives the traveller the best protection against trouble and inform him how exactly a case should be best handled for the cultural background. In almost all cases this will coincide with the law, but if obeyeing the law constricts choices without real cause or endangers a traveller disproportionally than it is no option.