The main purpose of hotels is to provide rest stops (which are located in the parking lots) for truckers to rest. All hotels in Euro Truck Simulator 2 have rest stops but not all hotels in American Truck Simulator do.
Most hotels are in cities and most (although not all) cities have at least one hotel situated. However, there are also a few hotels outside city areas.
In American Truck Simulator some hotels are called motels, but they essentially serve the same purpose.