There are many expectations that employers have of their employees. The basic one though is that they do their job and do it well. For the most part as long as the employee is doing their job, they will be able to keep it. However, some things are out of an employee or an employer's control such as a downturn in the market or a specific business. In these situations the employer may simply no longer have the money to pay all their employees and need to lay them off.
Most employees are known as at-will employees so they do not necessarily have any guarantees, but they do need to at least receive at least 60 days' notice ahead of mass lay-offs. This is known and worker adjustment and retiring notification laws and there are both federal and state laws on this subject, which are slightly different.
The federal law applies to companies with at least 100 full-time employees, while the California law applies to employers with at least 75 full-time employees. In both laws the layoff must affect at least 50 employees. In both, if the employer violates the law then they may need to pay back pay and benefits for the duration of the violation or up to 60 days, but the California law also includes a $500 fine. There are also some exceptions in both laws.
There are many reasons for layoffs in California and they by themselves are not illegal, but they need to at least give the employees notice to give them time to prepare. It is important that they are not just suddenly left without a job. Employers do sometimes break these laws though and they may need to compensate their employees as a result. The employees need to know their rights though so they can receive the proper compensation and experienced attorneys may be a useful resource.
Source: www.edd.ca.gov, "Worker Adjustment and Retiring Notification (WARN)" accessed on January 17, 2018