Tom Bombadil is a bizarre resident of the Old Forest who frequently (and sometimes annoyingly) speaks in rhymes. We can't quite pin down what he is, since no one in Middle-earth is quite like him. He calls himself Eldest, since he has been in Middle-earth since before the arrival of the Elves or Sauron. He appears to be something like the spirit of Middle-earth itself, though he is familiar with Middle-earth's people – he has spoken to Gildor Inglorion, and he knows Farmer Maggot (of all people!). Elrond later wonders if he should have invited Tom Bombadil to their Council, but Gandalf assures Elrond that he would not have come. Tom Bombadil has "withdrawn into a little land [the Old Forest], within bounds that he has set [...] and he will not step beyond them" (2.2.206).
While Tom Bombadil is not particularly interested in taking sides in the conflict against Sauron, he does help rescue Frodo and his friends from immediate danger twice, once from Old Man Willow and a second time from the Barrow-wights of the Barrow-downs. Tom Bombadil is perfectly happy to prevent evil when it is on his turf, but he doesn't get involved in abstract causes that would take him beyond his Forest.
When Frodo shows Tom Bombadil the Ring, he amazes the Hobbits by putting the Ring on without disappearing. The reason that Tom Bombadil is not subject to the power of the Ring is that he really, truly does not desire power or ownership over any one thing. He is perfectly happy to just keep living, without trying to change anything going on around him. Even wanting to improve things is a sign that you think you know best, whether you mean well or not. Tom Bombadil has none of that will to change things, either for evil or for good. It is not in his nature; he is truly willing to let things happen as they come.
Check out Tolkien's discussion of Tom Bombadil's character:
I would not, however, have left [Tom Bombadil] in, if he did not have some kind of function. 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 in 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. It is a natural pacifist view, which always arises in the mind when there is a war. (Source, 178-9; letter to Naomi Mitchison, 4/25/1954.)
In other words, even if Tom Bombadil seems kind of random – again, there is literally no other character like him in the whole series, and we never really see him again in the rest of the novels – Tolkien feels that he has a purpose. Tom Bombadil's function is to represent a particular wartime perspective. His presence in these novels acknowledges his totally neutral, hands-off perspective on the war as a legitimate one, even if the rest of the Lord of the Rings is concerned with the fight between Good and Evil.