And it does hurt to have an employee leave, in many ways. Besides the hurt feelings part, here are some other reasons why your boss may become a jerk after you tender your resignation.
They act defensive because they have a lot to defend. Your boss will get called into her boss's office and asked to explain why you are leaving and what she did wrong to make you go. If she can argue that you weren't that great of an employee in the first place, having you leave doesn't seem so bad.
Your boss's boss knows that the managerial relationship places a strong role in an employee's decision to leave, so your boss is now having to prove that losing a good employee isn't that bad after all. Unfortunately, you may get smeared during this defensive act.
Managers shouldn't do this, by the way. They should always be honest about the situation, but sometimes the desire to defend takes over.
Scorecards. Anybody heard of these things? Someone decided that we needed quantitative measurements for everything so that we could figure out what in the heck is going on in the company. I'm a big fan of scorecards, for the most part. But, turnover is a number on that score card for managers. If your turnover is too high, you're going to get dinged. This can affect your next bonus, increase and career at this company.
So, yeah, ouch. But, the problem with the scorecards is that there is not enough context and support around the turnover piece. If the company is too small to offer a lot of developmental opportunities, a good manager will consistently be preparing employees for their next jobs outside of the company. You would rather have a steady stream of good employees that leave after a few years, than mediocre employees who never go anywhere else.
Recruiting. I've never met a manager (outside of staffing) that enjoyed the recruiting process. Finding a new employee is time consuming and risky. You are leaving, and so now your manager has to replace you and that is a pain in the behind.
Being short staffed. The standard rule is that you give two weeks notice. I've never seen a professional level job filled in two weeks. Heck, it takes longer then two weeks to get everybody to sign off on it. So, when someone resigns, the manager knows that it will be several months of being short staffed, plus a training period.
Now, of course, a manager shouldn't take any of that out on the resigning employee. A manager should congratulate the employee on the new position and handle all the other things without any animosity. Managers should take time for self reflection and figure out what they could have done better and whether or not this is good for the company or not. Some turnover is good.
Just make sure that you handle your resignation as professionally as possibly. Make a plan to transition your work to your co-workers and stay positive. Your boss will get over your resignation. You'll need that boss for a recommendation later, so play nice right up until the end, regardless of the reaction you got.