Retention is more valuable than simply 'keep people who we pay less than market for'. It's not like a football team, where you have to figure out how to get underpaid people who are largely equivalent parts; even in retail, it costs you something to hire and train a new staff member.
Professional companies have even more at stake: if you have relationships with clients, if you are the primary developer for a major project, or if you are a popular manager, you give the company value personally, separate from your 'market value'. You walk out that door, even if they have very good knowledge transfer protocols, they lose something in you personally. You also are a sure thing - even if you're not a top 5% performer, they still know what you are, if you've been there a few years. If you're meets expectations, well, they know that, and know what they'd have to offer to have a 50-50 chance at another equivalent person.
Secondly, companies want to retain you and know that you need to be happy to stay. A person who feels he's underpaid is unhappy. A good manager should always discuss salary expectations periodically (at least once a year, at review time) with his/her staff. If your manager isn't doing that, there's no harm in discussing things with him/her in such a way that you are satisfied.
If you come up to your manager and say "I want a raise or I'm leaving", well, you're right: that's the beginning of the end. But if you come to your manager and say "Hi Betsy, I'm starting to get older and thinking about my future - might want to get married, have kids, buy a house, all that stuff. Can we talk about my salary? I'd like to know when I can expect a raise and/or promotion, and what the typical schedule is for someone in my position", you should get a reasonable response.
Or, "Hi Betsy, I've been working here for a few years with a fairly low salary since I started with no experience. But now that I've got 3 years' experience, can we talk about making sure my salary is commensurate with what someone with that experience would be paid?" After all, you are a different person than you were when you were hired - you have X years more experience, and a person with that experience hired off the street is probably paid more than initial-you was paid.
Either way, if you address it to your manager politely, not as a demand but as a conversation, it won't be viewed as a 'leave now' or anything like that. It's part of normal business, and something that if you're not doing at all, you're getting the short shaft. It's like buying a car - sure, you can just agree to pay what the salesman says, if you want to buy their kids extra Christmas presents, but they won't just write you off if you negotiate; negotiation is expected and built into the numbers.