Those ordinances probably came at a time when certain culture enriching activities were viewed as things that would lower property values and be annoying to live near; ie grandma& grandpa , aunts & uncles, mom &dad, kids and cousins all living like sardines in one house.
Just a guess, but cities used to pass ordinances to protect property values.
I see those as unjust laws. An unjust law is a law that interferes with private consenting adults who are not interfering with anyone else’s rights or freedoms. These laws are also unjust because they interfere with the private use of one’s own property that does not interfere with another’s rights or freedom.