I’ve always wondered if it was some sort of religious or cultural mild eastern hat that was just fashionable or if it has a more important meaning behind it.
You may be interested in this answer (Why are there so many photos of Turks wearing a fez from around the turn of the century?) that I wrote a few months ago. Tl;dr, the fez's popularity largely stems from its vigorous promotion by the Ottoman sultan Mahmud II (legislated as an official uniform in 1829) as a symbol of Ottoman cosmopolitanism and equality among social and religious classes.