Henry David Thoreau was an American essayist, poet, philosopher, abolitionist, naturalist, tax resister, development critic, surveyor, and historian, two of his greatest works are: "Resistance to Civil Government" (also known as "Civil Disobedience") and "The Mask of Anarchy". His ideals can be summarized by this statement: “the Government should not have more power than the bestowed by its citizens”.
Thoreau was an idealist; he opposed the oppression and tyranny from the government and I think that more people like him should exist for we need more free thinkers to defend the common citizen from the oppressive government we sometimes have.
Henry David Thoreau was even imprisoned for refusing to pay taxes in protest for the Mexican-American War and the slavery.
so, to give a final and direct answer to this question, Thoreau wrote Civil Disobedience after spending a night in jail for his protest against _____:
slavery
the Mexican-American War