While it's true that you can make more money elsewhere, lots of people take jobs for reasons other than money. As one example, nearly every game programmer I know could be making a ton more outside games but they don't leave game dev.
The reason you're supposedly supposed to get into public service is because you want to serve the public.
I know it's being naive on top of being fiction but it reminds me of this ep from West Wing where they recruit a press secretary who's making $550k a year in Hollywood and tell her the press secretary job pays $31k a year
https://www.youtube.com/watch?v=FsM_eeUyOBs