Whoopi Goldberg had/has dreadlocks (quite some quantity) so the hat was to cover them up.
Presumably
El-Aurian women don't have dreadlocks.
Durinda Rice Wood
, Senior TNG Costume Designer has given a convincing "out of universe" reason for Guinan's choice of hats... *
As for Whoopi Goldberg's character Guinan, Rice Wood also explained that she wanted her to look different without her typical dreadlock look and that's the reason Guinan is wearing large hats.
scifi.stackexchange.com/users/4907/Jaydee
We have seen a few other El-Aurians, most prominently Soran : Also, we have seen another male El-Aurian: Martus Mazur .
Also from Generations , when we meet the lovely Mr. Soran, we also see a lot of Guinan's people in one of their space stations .
Female El-Aurians sometimes wear hats: And sometimes do not: And the hat of the first one is quite different from Guinan's.
Since Guinan seems to wear civilian clothing (not a starfleet uniform), it stands to reason the hats are just her personal taste.
scifi.stackexchange.com/users/2565/bitmask
Guinan's hats durign the TV series are most likely her own style, since as you pointed out we never see anyone else wearing ones like them.
However, when we first see Guinan in the movie Generations
she is wearing a hat very similar to the ones donned by most of the other hat-wearing El-Aurians seen on the Enterprise B (as shown in bitmask's answer).
Why she, or any of the other El-Aurians, wore hats
was likely just as a stylish means to keep her hair out of the way, especially while working in Ten Forward.
You probably wouldn't be too pleased if your bartender's hair fell in your synthehol or ice cream sundae.
scifi.stackexchange.com/users/1234/Xantec
If you ignore the colors and texture of Guinan's costume it becomes obvious that what she is wearing is a slightly updated nun's cornette and habit.
Given her ever-placid demeanor and role as confidante to several characters her costume is a visual cue to the audience that cannot be accidental.
scifi.stackexchange.com/users/4096/Kyle Jones
Not sure if Star Trek Online is considered canon on the Stack Exchange, but Nelan on Earth Spacedock is another El-Aurian bartender and he wears practically the same costume, hat and all.
He's also a male, meaning that the outfit is most likely unisex.
Maybe it's some kind of "bartender uniform" in El-Aurian culture?
scifi.stackexchange.com/users/54417/Dzvfars Fdszvfvf
I think several of these answers are valid, I also suspect that aside from practical issues with the hats, the costume designer drew on South African Zulu head dresses called Isicholo.
scifi.stackexchange.com/users/69014/Morgan
Guinan dons two hats, if I recall correctly (pictured below).  My question is:  are these hats something special to El Aurians, something special to 24th century bartenders, or something else?   I don't recall ever seeing anyone else wearing either type of hat in TNG (and I've seen it all now!). I've noticed that both hats completely conceal the top of her head, but I don't know if that's significant.
What's the deal with Guinan's hat?
scifi.stackexchange.com
<star-trek><star-trek-tng><clothing>
scifi.stackexchange.com/questions/56755
scifi.stackexchange.com/users/22917/Often Right
The large hats were a way of covering Whoopi Goldberg's dreadlocks. They are also part of Guinan's personal style and taste. The hats are Guinan’s own style and she wants to look different without her typical dreadlock look. 
The hats are Guinan’s own style and she wants to look different without her typical dreadlock look. 