Thoreau wrote Civil Disobedience after he was jailed for refusing to pay his taxes. He refused to pay his taxes because he believed his money was going to finance the Mexican American war. He thought this was an unjust war because, first, the United States had no right to invade and annex Mexican territory, and second, he believed this war was part of a southern plot to spread slavery to the western United States.
Thoreau uses slavery as an examples of a terrible and unjust institution supported by a democracy, and argues that the government that governs least governs best, as it will most likely stay out of the business of passing unjust laws. Second, he asserts that moral law—the law of one's own conscience—matters more than the laws of the state.
Finally, he argues that individuals must break the laws of the state rather than violate their own consciences. People must understand that legality is not the same as morality. States can make terribly unjust laws, and these laws must be opposed. Thoreau states that in a country where people are imprisoned for not following unjust laws, all just men should be in prison.
Thoreau also expresses his belief that it is difficult for men of property to break unjust laws, because the state can seize their goods and make them miserable. It is people like him, who have little to lose, who are best positioned to oppose the state.