The debate over how Tom fits into the overall legendarium is one of those huge
ones on par with Balrog wings, and the link below is a good summary of some of
the theories on his nature (Vala, Maia, nature spirit, even Eru Iluvatar or the
tooth fairy).
I think that Nimrodel's reminder below that the name was that of one of his
children's dolls should always be remembered in these debates, because Tom was
first and foremost a part of the bedtime story world that gave birth to The
Hobbit. LOTR started out as a children's book, a much belated sequel to
the 1937 book we're now discussing in the RR, and Book 1 of FOTR has many
remnants and echoes of the adventures in that earlier storybook world.
The evil being faced in LOTR is much greater, but there is still a
lighthearted, hobbity tone initially that Tolkien adopted partly as a private
amusement for himself and his main reader Christopher (though the doll was
Michael's I think). Tolkien hadn't made the transition between the
children's book style of Bilbo's adventures and the epic style used to present
the War of the Ring, so the first adventure the embryonic fellowship encounters
is one that would easily fit into The Hobbit (Old Man Willos), and then Tom
comes to rescue them like Gandalf recuses the Dwarves from the Troll's stew
pot. The interlude at his house is a kind of fairy tale sojourn like the
Rivendell of The Hobbit or Beorn's house. Yet after the hobbits leave
that house and are taken captive at the Barrow-downs, the tone changes, and Tom
(who has revealed new depths in his knowledge and power during his talks with
Frodo and his playing with the Ring) becomes a stronger, more legendary figure
like the powers of the Silmarillion who fight a darker evil than a
foul-tempered willow tree.
So I think that Tom begins as another one of those quasi-magic figures we see
in The Hobbit who rescue the hapless travelers, but then shows that he is more
than he appears to be, and is actually fighting the much greater evil of the
leftover wigths of Angmar. These two initial adventures quickly change
the tone of Book 1 from the easy-going journey like that Bilbo went on to a
more high-stakes journey, and then when Aragorn joins them, the fight against
the now more sinister Black Riders becomes greater. I am leaving out the
Gildor episode here, but really the Tom episode in FOTR contains the first true
adventures our heroes encounter outside the Shire, and the two adventures with
Tom serve as a transition that tells the reader we are in a much more dangerous
universe now than we were in 1937.
This doesn't really answer what he is, but I now just see him as a bridge from
one style and manner of conceiving the invented world to
another!
Men do go, and have in history gone on journeys and quests,
without any intention of acting out allegories of life. . .
Most men make some journeys. Whether long or short, with an
errand or simply to go 'there and back again', is not of primary
importance. As I tried to express it in Bilbo's Walking Song,
even an afternoon-to-evening walk may have important effects.
When Sam had got no further than the Woody End he had already
had an 'eye-opener'. For if there is anything in a journey of
any length, to me it is this: a deliverance from the plantlike
state of helpless passive sufferer, an exercise however small of
will, and mobility -- and of curiosity, without which a rational
mind becomes stultified. Tolkien's Notes on W.H. Auden's Review of
The Return of the King, Letter #183