You asked: "Where can I find info on what makes an in-law legal or illegal."
Michelle's answer is good. Your city or locality will have regulations and can tell you whether it's legal or illegal.
You asked:" If no one complains, then is it OK to rent an illegal unit if it is in great condition?"
No. It's not legal to rent an illegal unit. Condition has nothing to do with it.
You asked: "What is the risk of renting an illegal unit, to help pay a mortgage?"
In addition to Michelle's comments about property damage, there's a whole lot else. Let's see: There's a liability issue. Suppose your tenant slips and falls and breaks a leg. He sues you. Suppose your tenant assaults someone (a neighbor, for instance). In those cases, you may find yourself on the receiving end of a lawsuit. Or suppose your tenant steals something from you. Or suppose the tenant doesn't pay rent and you try to collect. I'm not a lawyer, so this isn't legal advice, but you might insist you have a valid lease, signed by both parties. But is the lease valid if it applies to an illegal structure or dwelling? Hmmm...
Just a few things to consider.