When I read LOTR I asked myself the same question. He seemed like an anomaly, who weren't supposed to be there, but I knew that Tolkien wouldn't have him appear in the books, if it weren't for a certain purpose. Now I know that the purpose, was to make the valar appear in Lord of The Rings, as a reference to his earlier work (Silmarillion). He wanted to involve a valar, without making it obvious but for the sake of his own amusement. Now you might say that I say this, without anything to back me up. But check out this link
http://www.cas.unt.edu/~hargrove/bombadil.html
It explains all!