Tolkien was writing poems about Bombadil long before he ever started on LOTR. Inspired by one of his kids dolls that was flushed down the toilet, he was a nature spirit of the English countryside.
From Tolkien's letters: "Tom Bombadil is not an important person to the narrative. I suppose he has some importance as a 'comment.' I mean, I do not really write like that: his is just an invention, and he represents something that I feel important"
"I might put it this way. The story is cast in terms of a good side, and a bad side, beauty against ruthless ugliness, tyranny against kingship, moderated freedom with consent against compulsion that has long lost any object save mere power, and so on; but both sides in some degree, conservative or destructive, want a measure of control. But if you have, as it were, taken 'a vow of poverty', renounced control, and take your delight in things for themselves without reference to yourself, watching, observing, and to some extent knowing, then the questions of the rights and wrongs of power and control might become utterly meaningless to you, and the means of power quite valueless..."