He believes that it should be done when the law forces them to treat fellow citizens unfairly. This mostly revolves around his belief that slavery was bad and that a government that supported slavery should be opposed. Also this was helped by the mexican war which was not endorsed by him.
Read the quotation. under what conditions does thoreau think people should disobey the law?