My business is primarily commercial real estate, but we’ve always had some business in residential rentals. I have friends in the industry who that is their only type of property. Restrictions like this are incredibly common but are likewise incredibly frequently ignored.
I have a friend who has rented out lots of homes to students on Virginia Tech’s campus, and this is a very common approach in college towns–his family got started in the business back in the 1950s with his grandmother, she owned a few 4 or 5 bedroom houses that she rented out to young men who wanted to live outside of the dorms. That’s now grown to a hundred or so properties today. A typical home they own is one they probably bought for very depressed values, typically built before 1950. It usually had a number of features that would have made the home unattractive to a single family purchaser–serious repair needs, location issues (most families these days don’t choose to live super close to a college campus due to concerns about student parties, general loudness etc), they buy the house up, make some changes necessary to pass the barest of code inspection, and then generally they start renting each bedroom out to individual students.
He has several homes he purchased in the 1980s for under $20,000 that now rent for around $500/room at 5 rooms per, meaning he’s making $30,000 in rent a year off a property he paid $20,000 for decades ago–and with the general boom in student housing districts up until 2020 the land alone is now worth many times what he paid for it.
He and landlords like him have several common strategies for bypassing zoning laws like this, it will all depend on the specifics of the law, but none are really ironclad. For example a common one is “no more than 3 unrelated adults” restriction, which is sometimes colloquially known as a “brothel restriction” because small town lore will often suggest the origin for the law was intended to prevent a bunch of unmarried women from cohabiting since that could allow them to operate a brothel. The truth is most of the time the origin of these laws is the same as you would expect today–single family homeowners simply not liking multifamily houses or neighbors. Landlords would rarely if ever support these restrictions–we generally make more money off of a multifamily building than a single family one, all other things being equal.
One common loophole around the “x number of unrelated adults” restriction is having the tenants say they are cousins. Many of these restrictions ill-define “familial relation”, and it ends up almost none of the municipalities that pass such ordinances are interested in the meat of enforcing them. It would actually be a big expense and headache to many of these towns “proving” two guys aren’t related.
Another common one is to physically subdivide a single-family home. My friend with properties in Blacksburg has several 5 or even 6 BR houses that are physically duplexed now. A common approach is to block off the top or bottom of a staircase, thus making it so you cannot travel between the main and 2nd floor any longer. Then you either build a proper entrance/egress to the 2nd floor or leverage one that already exists, and now both units are two separate addresses. It sounds a little hinky but there are entirely code-friendly ways to do this, obviously you just have to make sure the 2nd floor has the appropriate number of egresses and emergency exits down to comply with the fire code.