You are nothing more to any company than a line on a spreadsheet. They look at the cost of keeping you as an employee versus the cost of dumping you. A company accountant ran an algorythm on a speadsheet and you are choosen. You may have has a less than stellar review 5 years ago aka your boss is toxic. Perhaps your department is a cost center that needs to be trimmed to improve the balance sheet, or you make over the median salary for someone in your band. They often outsource to replace IT departments and marketing/sales. They could cut staff as a way to hide losses, without admitting it to the street. What ever the cause you are gone. Do the stages of grief, own it, but keep moving.
When Unilever laid me off 20 years ago, I had small children, alimony, and lots of bills. I drank th corporate Kool-Aid back then. I had to su-k it up and make finding a job my job. I worked retail while I looked, I did odd freelance jobs to keep my skills up. I did take another job at a lower salary 2 years later at another insurance company, then went to Cigna. The thing was, I survived, and when I felt the enviornment at Cigna had nothing left to offer me after 5 years, I put out my resume and moved on. I fired Cigna. I realized my job doesn't define me. I depend on me, not a company. It was a tough journey that humbled me. I survived and then I thrived.