It is important to understand that what is legal and what is moral are two separate issues. Many people confuse the two. Not only is this a mistake it can be dangerous. I have heard people ask "is that even legal to do?" and they ask such a question in regard to a moral issue, what they do is confuse moral with legal. No, moral and legal are completely separate concepts. The goal of law is to be promote moral justice but there are a huge list of laws which are immoral.
Consider this thought experiment. Marijuana is illegal in the United States. One day it becomes legal. What did this do to the question of whether or not marijuana is moral or not? If you are a person who thinks that legal is equivalent to moral and illegal is equivalent to immoral then there is a puzzling question. All the days before when marijuana was illegal it was immoral and then when it became legal it became moral. How can it change its morality status like that?
The above question illustrates the problem with identifying law with morality. However, for a great deal of human history the identification of law with morality could be made. Thousands of years ago morality was used as a tool to control people (in fact, it is still largely used to that effect today). To control a population of people you needed to make them develop morals in such a way so they obeyed the law. Morals were build around the law rather than the other way around. The Torah is a good example of this. It is not the case that the Torah was written as a book of morals and then laws developed to suite these morals. It is the other way around. When the primitive ancient Israelites had their state they had laws. To make the people most obedient to the law they said that these laws came from God, that is, they were identifying the law with morality. So in the minds of the Israelites the laws were manifestations of God's commandments, hence this is why they were careful not to break the law. But in truth it is the other way around. Morality (of the Torah) was developed as a way to suite the ruling laws in ancient Israel.
We must remember that there are lots of immoral laws. Just consider the Fugitive Slave Act. It is our responsibility to break the immoral laws. This is what civil disobedience is about. I am not saying to necessarily get ourselves with trouble with the law (that would be unpleasant) but I am saying to ignore the laws in secrecy as much as we can if they need be immoral laws.