Maybe you should look up the rash of hotel fires before some of those regulations were put on the books. Or consider the fact that many of our homes are in apartment buildings and we didn't sign on to have an illegal hotel in the apartment next door.
What fires have to do with it? The OP didn't complain about fire. It complained about his guests inviting other people, having wild sex party and trashing the apartment. Tell me that never happened in hotels.
You make it sound like OP was running a crime syndicate there. He just let people stay in his place for a couple of nights. People do it all the time. I did it many times for my friends and was the beneficiary of the same many times. One time he trusted wrong people's recommendation and it didn't work out. It could as well happen to anybody - you could trust your best friend's friend and let him stay at your place and he could invite his pals and turn the place upside down. Nothing to do with fire codes.