For a start: everyone resigns because of multiple factors, and money is of course one of them - but when handing in their resignation, in order to leave on a positive note they'll focus on factors outside of anyone's control. Usually people tell me they're leaving because of something like because they want to explore new challenges, or that they just feel that it's time for a change, or because a shorter commute will give them more time with their kids.
Such reasons do not invite a counter-offer. You want to spend more time with your kids? Good for you! I won't try to argue you out of it.
For another thing, when someone offers their resignation you only have a few hours to pull together a counter-offer - so on the occasions when I was able to make counter-offers, they were pretty meagre. I always get my team as close to the top of the salary range for their role as I can, so there's no headroom for anything big without getting a bunch approvals for a special exception.
And finally, a lot of people who leave get offers that are kinda good, or at least good for their situation. If a kid's leaving my employer, who most people haven't heard of, for somewhere like OpenAI? That recognisable brand might well be great for their career. Leaving to get a PhD? Great, so long as they know what it really involves.
And if I wouldn't council them to stay, I'm not going to be able to sell a counter-offer persuasively.
First, you should be giving people pretty good compensation packages. If you're underpaying massively in the first place, then you're going to consistently lose your best employees.
Second, you should recognize who the best employees are, promote them, and pay them more.
Third, you should be giving people at the same level very similar compensation packages. It will get a little bit off but you want to try to keep things fair.
Given these rules, counteroffers lead to trouble. If you have ten equal engineers and one of them is overpaid 1.5x, do you just keep them overpaid by 1.5x the rest of their career as you promote them? Do you keep it a secret from the other ones? Etc etc.
Usually when a counteroffer seems like it makes sense you are screwing up one of these principles of a well-run company. Maybe you're underpaying people but also not getting what you're paying for. You're paying 40th percentile pay and getting a 20th percentile team. You give every engineer an equal salary. Then your star engineer gets an offer from Google that doubles his pay.
Yeah, then it makes sense to counteroffer. But it would be better to not be in this situation.