It's not just for the benefit of hotel owners. Cities typically charge huge taxes on hotel stays, so illicit hotels are dodging taxes. And there are actually some vestiges of regulations directed at protecting consumers from hotels that are firetraps, lack adequate ventilation, etc.
Well, you're right, that too. Though I'm not sure what this tax is for - i.e. what exactly is it except "these people do not live here, so they aren't our voters, so fleecing them a bit won't hurt"?