The first thing is that it is virtual hosting. You don't really get a machine, you get a virtual one . And you can have a lot of virtual machines under a Physical one. SO this divides costs a lot.
Also I'm not sure but I read somewhere that in the beginning the idea for companies like Amazon or google was to reuse their infrastructure(hardware, bandwith, electricity) by selling virtual machines inside their servers. So they invest in the machines for their services but try to pay part of this inversion renting part of it.