The changing setting between Huckleberry Finn's experiences on land as compared to his life on the river develop the theme of freedom in the novel through Twain's sharp perceptions and portrayal of civilization versus nature.
The land clearly represents civilization. Every time that Huckleberry and Jim set foot on land, a new conflict arises. The people they encounter for the most part are duplicitous, greedy, and self-centered. Equally often, Jim and Huck discover that the people on land expect something from them, and they feel the force of societal expectations. More than once, Huckleberry and Jim just nearly escape their doings on land to find peace on the river.
The river represents peace and tranquility. Free of social expectations and the pressures of civilized life, Jim and Huck feel that they can relax and be themselves on the Mississippi in a way that they could never experience on land. Huck "had never felt easy till the raft was two mile below there and out in the middle of the Mississippi" (Chapter 18).
Where both of the characters felt trapped on land (Huck by the Widow Douglas, and Jim by Miss Watson), they feel free on the river to do what they want and act how they choose.
There warn't no home like a raft after all. Other places do seem so cramped up and smothery, but a raft don't. You feel mighty free and easy and comfortable on a raft. (Chapter 18)