Tom Sawyer is drawn to Huckleberry Finn because Huck represents freedom.
Huckleberry came and went, at his own free will. He slept on doorsteps in fine weather and in empty hogsheads in wet; he did not have to go to school or to church, or call any being master or obey anybody; he could go fishing or swimming when and where he chose, and stay as long as it suited him; nobody forbade him to fight; he could sit up as late as he pleased; he was always the first boy that went barefoot in the spring and the last to resume leather in the fall; he never had to wash, nor put on clean clothes; he could swear wonderfully. In a word, everything that goes to make life precious that boy had.
This paragraph from chapter six sums it up beautifully. Huckleberry clearly, from Tom's point of view, is not subject to the rules of civilized society by which Tom feels confined. Huck can come and go without checking in and sleeps wherever he wants. Tom envies the fact that Huck doesn't have to go to school or to church, two places where Tom must, again, follow the rules of society and is subject to reprimand when he does not follow the rules. Huck sheds his shoes as soon as weather permits, something else that represents freedom from societal obligations to Tom. Huck fishes and swims whenever he wishes, two activities that represent freedom from society to Tom and to most boys. Also, Huck swears whenever he feels like it. Most boys go through a "rite of passage" where they swear to demonstrate their autonomy, their freedom from their mothers and societal rules. Because of this, Tom sees Huck as a boy who is, from Tom's perspective, truly free to choose his own destiny. What he fails to realize is that Huck has nobody to feed him, clothe him, and love him - all things Tom takes for granted at the beginning of the book.
His outlawish behavior