It's well-accepted in psychology/sociology that moral development extends beyond simply following the law, i.e. using the law as a stand-in for moral principles. E.g. in Kohlberg's stages of moral development[1], there is a post-conventional stage where an individual develops a moral code independent of laws, and views laws as a social contract that can be disobeyed if it violates his/her morals. Laws are a good guideline, but are not an absolute moral framework.
[1] https://en.wikipedia.org/wiki/Lawrence_Kohlberg%27s_stages_o...