Finally, think that if the space was taken from a tenant garage, that tenant is entitle to a rent reduction and you to an abatement of the unit. In San Francisco lots of illegal unit are not only in garages but in top of building structure "bonus rooms" usually with decks, those are the favorites of building inspectors. Building code violations are plenty when you did not seek permission!
When you are looking at the mandated disclosure is SF you will be told if the unit is warranted or not and you will also be able to see if the property is zoned for multi-family RH-2 or single family RH-1 in the 3R.
There are many drawbacks to creating a multifamily dwelling on a property that isn't designated for that. All can go well but as Michelle said insurance could be a problem if anything were to happen and many things can happen.
When someone goes into the business of being a landlord, which is what you'd be doing, they are aware of the risks and have the proper insurance and advice from lawyers etc. You would be subject to all of the states eviction laws and the rent control ordinances of the city and if you make your tenant upset they have you right away because you are renting a unit that is not supposed to exist. So there you are with an angry tenant in your house that you have to evict legally or get slapped with an unlawful eviction lawsuit on top of having to get rid of the unit. Wrongful eviction insurance is very expensive but very neccessary insurance for any landlord.
Your question should be put to a lawyer and then you need to decide if the risk is worth the benefit for you. Also I hear form many neighborhood groups that oppose the creation of these units and are actively seeking them so that they can notify the building department and have them abated (torn out).
Here in San Francisco with our rent control laws, which apply to buildings built before June 1979, taking on a tenant has certain liabilities. I've included the rent board's web site. Feel free to email me for additional resources.
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.
Hope this is helpful.
Great question. The safest answer would be that you would need to check with the city in which the property is located in the see what their requirements and restrictions are for in-law units. Some cities require you to live in one of the units, some have a 600 square foot maximum and more.
The risk would be someone turning you in to the city and the city shutting you down and then you need to make arrangements for you tenant to vacate. Good luck.