TL;DR - It doesn't work out for everyone. ![:-D 😄](https://mangolassi.it/assets/plugins/nodebb-plugin-emoji/emoji/android/1f604.png?v=3hrg7a1ige4)
It's not quite as simple as how @PenguinWrangler may be explaining it. I work for the gov't (state) and have looked into this (I have way more student loan debt that I'm willing to admit, unfortunately)...
You must make 120 qualifying payments towards a federal student loan before they will forgive the loan. They will forgive the remainder of the federal loan once that requirement is met. And these qualifying payments do not start until you're on an Income Based Repayment (IBR) plan.
If you leave the public sector that clock resets, so you must work for the public sector for the entire 120 payment stint.
You must also be on an Income Based Repayment plan. In my case, because I have so much friggin' student loan debt, my IBR payment was astronomical. And, for some reason I could never understand, the calculations for my IBR payment made it so that I'd have the loan paid off in ~120 payments anyway. so there would have been minimal, if any, money to be forgiven. I think it was due to not having any dependents at the time (wasn't yet married nor had any kids). This was in 2010.
I did have, however, a substantial (to me) mortgage that I valued more than paying my student loans off early (which worked out well for us fortunately).
Fast forward to 2013 where I was happily married and had newborn twins. Oooh, great, time to look into the student loan forgiveness plan! Nope. Given the 3 years of payments I had already put in (which did not count since it wasn't on an IBR plan), the calculations still balanced to where I'd have the loans paid off within the ~120 payment timeframe.
It would've been a nice perk, but I have to think of it in terms that I'm lucky to be able to afford to pay off my student loans and still live a somewhat middle-class life.