Purely cosmetic. A top hat has no stats, no combat use and no practical function whatsoever.
It is expensive because of how it is obtained rather than what it does. Top hats come out of level 3 clue scrolls, and the rarity of that particular reward is what keeps the price high on the Grand Exchange.
So you are buying a look, and a fairly conspicuous one. If that is what you want, fine; just do not expect it to help you fight anything.