Innaresting how none of the articles I have seen on this story mention the reasoning behind the original law. Laws like this were put on the books in the early part of the 20th century when cities really started booming with new industry. It wasn't unusual to have four or five people living in a one bedroom flat (with no running water, heat or toilet). Often the people living like these would be a bunch of young, unmarried folks of the same sex who had come to the city to seek their fortune. Sharing a flat was the only way people could afford to live on their tiny wages, but it led to major health and safety problems. This overcrowding was a financial burden for the cities, since they had to foot the bill to put out slum fires and hospital influenza sickies. In an attempt to regulate the number of people living in a single flat or house, some cities enacted residency laws, like the one in St. Louis, stating that if two or more adults live in the same domicile they must be related by marriage. Minors are usually exempt under these laws, as they do not have the means to live independently.
I haven't seen the exact wording of the law in question, but it seems like the St. Louis story is a case of following the letter of the law rather than the spirit. That, and case of right-wing asshattery.