I would imagine that it's all dependent on the agreement between employer and employee. For instance, I have a contract that says should I leave my company, I'm not permitted to work with similar clients, or at similar companies, etc. for two years.
So think about the ramifications of that. That company fires you. Your skills happen to be specialized enough that your qualifications can only land you a job with one of those "similar" companies. You are legally obligated to sit on the sidelines for 2 years. Trying to live on unemployment or any low-paying job you can get that isn't with a "similar" may be tough.
So how is the firing party affected? They don't have to wait 2 years before replacing you, so they can do so quickly (probably already have your replacement lined up before firing you) and carry on making money. So they suffer no great loss but you potentially feel meaningful pain for 2 years.
How should this work? If a company requires you to sit out of a skilled job for which you are qualified, PAY you for sitting out. In other words: in exchange for preventing you from replacing your skilled job for 2 years, pay you for those 2 years. As is, there's tremendous disadvantage to the skilled employee who must take on this obligation without compensation beyond the point at which they lose the job.
Imagine the scenario of taking on such a job and obligation for a few weeks, then losing the job (firing, downsizing, etc). No time to set aside savings from compensation from that job, yet you have a 2-year obligation to not take a "similar" job. Company loss: little-to-nothing. Employee loss: job + 2 years of getting a similar job.
Compensation-limiting requirements should be purchased, not mandated for nothing. The lone employee is at tremendous disadvantage in such situations.