In most jurisdictions, it is a legal requirement for there to be a working telephone in every guest room. And maintaining this infrastructure costs money.
Years ago, hotels were making a decent profit because you had very little other choice but to use the in-room phone. Now with mobile phones, VoIP etc most people don't use the phones but the hotels still have to provide them. So charging, even what people perceive as obscene amounts of money, is simply a method of cost recovery at this point.