There are federal laws against firing people for racial, sexual, or disability reasons, but not in general, as in you have to have a good reason. Some states add additional reasons, like sexual orientation and the like. There are ongoing court cases claiming sexual orientation firing is really a sexual (boy/girl) firing, and thus covered under federal law, but that's not settled yet.
More and more states are becoming "right to work" states, which means you can get hired at a union shop without joining the union, or at least paying dues to it. This is all state-level law.
But in most states, there is "at will" emloyment, which means they can get rid of you for any or no reason at all (subject to above.)
I used to work for a large multi-national that, in a mid 2000s downturn, carved off lots of people, including engineers, from all facilities worldwide. Except for the German division, which had 300 engineers. That division actually bragged about firing essentially no one, which was also consistent with German law which made it difficult.
Corporate went to them and the German government and said, "We can lay off 100 people, or we can lay off 300, if you get our drift." Projects regularly involved people on multiple continents, and shifting of who did the work was of little importance. The government backed down.