Obedience to “the law,” as such, can never provide moral exculpation for an action. After all, who makes what passes for “the law”? Is it not the dominant organized crime syndicate in the territory where the actor resides?
One may obey “the law” out of prudence, in order to avoid the syndicate’s punishment of those who fail to comply with its dictates. But such prudential action is independent of morality and cannot serve as a surrogate for it. Not uncommonly the opposite is the case.
Very often those who obey “the law,” especially by administering or enforcing it, act in ways that violate the natural rights of others.