The term "Bohemian" derives from Bohemia, which is a region in eastern Europe (these days, it's part of the Czech Republic). In the mid-1800s, this region was associated with the Romani people (also known as gypsies), who were free, wandering, nomadic folks. The Romani didn't actually come from Bohemia - they merely travelled through Bohemia on their way to western Europe. But, the name "Bohemian" stuck for these free-wandering folk.
During the early to mid-1800s, the label "Bohemian" started to be applied by some French people to writers who were a little different. Free thinkers. Eccentric. Like the stereotypical gypsies.
Eventually, the label came to be applied to anyone who lived free, or embraced an alternative lifestyle, or rejected a conformist life.
There was even an Italian opera in the 1890s called 'La bohème' ("The [female] bohemian") which was extremely successful (and adapted a century later into the modern musical 'Rent').
Fifty/Sixty years later, it was similarly applied to beatniks and hippies.