It is a form of price discrimination, but it's actually more straightforward than that. These "nicer hotels" are primarily business hotels, rather than hotels targeted at personal travelers. Business hotels, at least in the US, take their guidance from the US Government in the form of the GSA. The US Federal government is one of the largest employers in the US, and most businesses limit their per diem rates for expenses to match GSA rates because these rates typically infer a tax advantage to the business. These rates are published annually by locality:
https://www.gsa.gov/travel/plan-book/per-diem-ratesThis of course isn't always true, but it does provide a strong price anchor. Importantly, the GSA historically separated per-diem for the hotel stay, food and beverage expenses, and "add-on amenities", which included things like WiFi. This is a major factor for why hotels historically charged for WiFi at higher priced places targeted at businesses (e.g. may have an attached conference center or meeting spaces) vs hotels targeted at personal travelers.