It's as if you never made that money.
- Assume your monthly paycheck withholdings are exactly right, and therefore you would normally owe nothing and get no refund at tax time.
- If you donated $5,000, then from the government's point of view, you have paid taxes on 5k that you effectively never made (and they don't know that).
- So now you will get a refund on the taxes that you would have paid on that $5k.
- You will not get a $5k refund. You get a much smaller fraction back. The exact amount depends on how much income taxes you would have normally paid on that $5k.
The intent is to not penalize people for donating, not to save them money.