@user178049 is correct in that "[distinguish] the good from the bad" is an expression. Though you could fit other verbs in there besides just "distinguish." For example, you can take the good and take the bad, and then you've got the theme song for an American sitcom from the '80s.
The point is really that taking out the articles changes the meaning a bit (or at least makes the meaning a bit more ambiguous).
One must learn to distinguish good from bad
is a perfectly acceptable English sentence. But that's not super hard for most people. Little kids generally understand the difference between good and bad, or right and wrong. The trick is applying the theory to the real world.
In the real world, you've got gray areas. You've also got things or people or ideas that might seem good or bad on the surface but are actually the opposite.
That's why we add in the articles. "The good" and "the bad" refer to the specific things in the world that are good and not bad, or vice versa – whatever those things may be. (So they're "specific," but only sort of.)
In answer to your other question about "distinguish," I would say it is okay here. That is just a simple infinitive. You could say "how to distinguish," though; that's okay too.
One must learn how to distinguish good from bad
implies maybe a slightly different emphasis than
One must learn to distinguish the good from the bad
But I'd say they both get at approximately the same idea.