Like a lot of businesses, they win on the averages, which means lucrative customers subsidize the money-losers. This is par for the course.
It's the health club model. The people who show up everyday are subsidized by the people who never show but are too guilty to cancel. When I sent 2 DVDs a day to Netflix, they lost their shirt on me, and made it up on the customers who don't. In those "free to play" MMOs, actually 95-99% of the players never pay and are carried by the 1-5% who spend significantly.
Acquiring a customer costs money
In business thinking, the overall marketing cost of acquiring a new customer is pretty big - $50 to $500. On the other side of the credit card swiper, they pay $600 bounty for new merchant customers - there are salesmen who live on converting 2-3 merchants a month.
That's because as a rule, customers tend to lock-in. That's why dot-coms lose millions for years giving you a free service. Eventually they figure out a revenue model, and you stay with it despite the new ads, because changing is inconvenient.
Servicing customers costs money
When you want to do a banking transaction, they must provide the means to do that. Normal banks have the staggering cost of a huge network of branch offices where you can walk in and hand a check to a teller. The whole point of an ATM is to reduce the cost of that. Chase has 3 staffed locations in my zipcode and 6 ATMs. Schwab has 3 locations in my greater metro, which contains over 400 zipcodes. If you're in a one-horse town like French Lick, Bandera or Detroit, no Schwab for miles. So for Schwab, a $3 ATM fee isn't expensive, it's cheap - compared to the cost of serving you any other way.
There may also be behind-the-scenes agreements where the bank that charged you $3 refunds some of it to Schwab after they refund you. It doesn't really cost $3 to do a foreign ATM transaction.
They make out on credit card transactions
Most debit cards have a Visa or Mastercard logo. Many places will let you run it as an ATM card with a PIN entry. However everyone who takes Visa/MC must take it as a credit card using a signature. In that case, the merchant pays 2-10% depending on several factors.** Of this, about 1.4% goes to the issuing bank. This is meant to cover the bank's risk of credit card defaults. But drawing from a bank account where they can decline if the money isn't there, that risk is low so it's mostly gravy.
You may find Schwab is doing OK on that alone.
Also, don't use debit cards at any but the most trusted shops -- unless you fully understand how, in fraud situations, credit cards and debit cards compare -- and are comfortable with the increased risks.
** there are literally dozens of micro-fees depending on their volume, swipe vs chip, ATM vs credit, rewards cards, fixed vs online vs mobile, etc. (Home Depot does OK, the food vendor at the Renaissance Faire gets slaughtered). This kind of horsepuckey is why small-vendor services like Square are becoming hugely popular; they flat-rate everything at around 2.7%. Yay!