Something illegitimate is unlawful, or improper. If you're a doctor, even a great doctor, but you were never certified by the medical board, then you're an illegitimate doctor.
Illegitimate has the root for "law" in it, and something illegitimate is outside the law or custom. A child not born to married parents is known as an illegitimate child, although so many people are making different choices about how to raise families, that the stigma is dropping away, especially if the child isn't the result of philandering (cheating). In King Lear, Edmund is mad that he's an illegitimate son, because it means he can't inherit the throne.