It's all about profit, I'm afraid.
The actual cost of processing a visa is generally much, much less than the fee they charge for it.
From the fees transparency data, for proposed fees in 2017/2018:
Visitor visa: £89
Actual cost to process: £142
Fiance/spousal visa: £1,464
Actual cost to process: £423
FLR(M) visa: £993
Actual cost to process: £147
ILR: £2,297
Actual cost to process: £252
Tier 4 visa: £335
Actual cost to process: £168
Tier 2 General visa: £1,174
Actual cost to process: £139
Naturalisation (UK citizenship): £1,282
Actual cost to process: £386
https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/606616/Unit_cost_table_2017.pdf