Sometimes, hair length can be a safety issue when dealing with machinery, such as in a print shop. However, you can pin your hair up or wear it under a hairnet to keep it safe and out of the way.
In other places, long hair can be a safety issue when dealing with people. There are reasons why you will never see a long-haired prison guard. Yes, long hair is against the prison dress code, but it's also a real safety hazard when working with inmates--which is why it's against the dress code.
Some places simply have an image of professionalism that they want to maintain. Want a job at a high-priced brokerage firm or bank? Want to work in the corporate world? Then your hair had better look corporate, and all but very neatly trimmed beards are right out.
Long haired men, unfortunately, have a stereotype of being lazy, irresponsible, drug addicts, poorly educated, and depending on others to support them.
Long-haired women, for what it's worth, have a stereotype of being womanly and pleasing to look upon if they have long hair or (in the corporate world) neatly pinned up hair.
Do I think that's fair or true? Of course not. But I did live through the Sixties, so I know firsthand how that stereotype for men was born. The fact is, first impressions are strong, and if you have long hair, that's going to give a certain impression to employers, wrong or unfair though that impression may be.
I have a friend who used to be a photographer for a hospital. He could have gotten a promotion if he had only cut his hair. (He has gorgeous, silvery-white hair that I adore.) He chose to keep his hair rather than keep the job. I personally think that was foolish of him, but that was his choice. He has been working **** jobs ever since--and he has a child to support.
There are jobs you can have--some high-paying--even if you have long hair. One word of hope--fashions do change. In the Sixties, no men at all would have been employed if they had been required to have short hair. So it won't always be this way.
I can understand wanting to keep your hair--I'd hate to have to cut my own hair for a job. After a point you have to ask yourself which is more important, your freedom of fashion or your ability to support yourself?