Since when is it illegal to sleep in a motor vehicle? I used to sleep in my station wagon all the time.
It’s probably a local ordinance designed to force tourists to pay for hotel rooms, which benefits both the local businesses and the tax collector.
One can also imagine that, if there were lots of teenagers sleeping in cars at Myrtle Beach in the summer, with access to bathrooms uncertain, the sanitation would suffer.