Better put, the relationship you have with your employer is a business relation ship. It's not personal. They are not your friends, nor your enemies. It's simply a convenient arrangement between the two of you for as long as that lasts. And it might become convenient for either side to change that arrangement at any point.
The more you earn, the higher the risk that at some point somebody decides that they want to spend less / smarter. So, your risk increases with your salary. That's fine because it enables you to mitigate such a scenario by having savings.
I've been part of a big layoff round once. It wasn't personal. That was just my employer rounding up a large group of people to cut some meaningful chunk out of their salary expenses. It wasn't the last round either. The company, Nokia, ultimately got out of the phone and map business (I was in the maps unit). The final head count reduction was in the tens of thousands. A lot of those have since had successful careers and the Nokia implosion spawned quite a few successful companies.
But getting layed off is a bit of a rough ride. You feel bitter, angry, insulted, etc. But on reflection I actually got a fair deal and honestly I needed the wake up call that job security is a big illusion. I was just coasting in my career and a bit too comfortable. The moment was perfect as I was still in my thirties. This stuff gets harder as you get older, less flexible, and more dependent on job security. I've been doing startups and freelance work ever since. Which means I'm my own boss now and I've learned a lot in the decade since that happened.