Yes, it was essentially a "fashion item" rather than a practical thing. The function of the hat was to be a hat - that is, gentlemen had to wear hats because gentlemen covered their heads, not because they needed to keep the sun out of their eyes like some kind of laborer.
At the beginning of the seventeenth century, men's hats were similar to the stereotypical "Pilgrim hat", as in this portrait of Sir Thomas Kennedy of Culzean: a tall, round crown with a medium-width brim, and often a noticeable band. By the 1630s, the emphasis had shifted from the crown to the brim, shown in this familial self-portrait by Rubens, which is sometimes called a "cavalier hat". This basic shape remained fashionable through the rest of the century ... but by the 1680s, some men were beginning to turn up the brims in a flashy way, sometimes at the sides, sometimes in front and/or back, and sometimes in full tricorn fashion. By the turn of the century, fashionable hats were worn with the brims turned up as a classic tricorn as a matter of course.
There's not a lot of detail to give here - it was a fashionable variation that caught on, and held on long enough that it became a standard "type" rather than just a style.
It was a civilian and military fashion at the time and quite practical regardless of your initial thought. Cocked hats (as they are referred to in the 18th century) could be easily unlaced on the sides to bring down the brims for protection against the rain and sun, which was commonly done by British soldiers in the Southern campaign of the American War for Independence. The cocking also allowed muskets to be shouldered, although the hat would have be turned askew so as to not have it knocked off. A wide brim would not allow for that. I have heard of some of my naval re-enactor friends tell me that the cocking allows it to be more aerodynamic and not let the wind blow it off as easy. I cannot 100% confirm that though.
The cocked hat remained in fashion until the late 18th century when it was replaced by the top hat for civilians and shakos for soldiers. Military forces often looked at civilian wear for uniform fashions and with the civilian change, they changed as well.