William Howarth at The American Scholar:
Walden is a literary accident. It began as a ragbag of recycled talks, scrapped bits of essays, and a great deal of personal venting. Many passages seem addressed to an invisible companion. Midway through his pond sojourn, Thoreau spent a night in the Concord jail for refusing to pay a poll tax that funded, in his view, a pro-slavery war with Mexico. After someone (possibly an aunt) paid his fine, he went to climb mountains in Maine. Caught in a storm high on Mount Katahdin, he took shelter near a patch of burnt forest, where the sight of regenerating foliage filled him with wonder: “The solid earth! The actual world! The common sense!” Thoreau rarely used italics or exclamations, but in this passage from The Maine Woods, he needed half a dozen to accept loss and seize life. “Contact! Contact! Who are we? Where are we?”
The two experiences, jail and mountain, became fodder for public lectures, but they also transmuted Walden from parochial rant into cosmic encounter. As literary historian J. Lyndon Shanley demonstrated in the early 1970s, that evolution required numerous distinct drafts, over nearly a decade. You can see the book’s outline, rising like a trout to the surface, in other early writings: his Journal entries on hoeing beans and plastering a house; a lecture on “getting a living” that argues for a simple life; a survey map of the pond, hinting at its unseen depths.
more here.