You have to ask why is it that the NHS cannot provide enough people to fill a shift but an agency can? Either the agency is paying the nurses/doctors more with better conditions or they're somehow godlike in their recruitment abilities vs NHS recruitment (which is very unlikely).
I don't understand why the government isn't looking for ways to defeat the need for agency work if it's costing this amount of money. I also don't understand why a pay-rise is unaffordable but imported expensive agency work is. It's these sort of stupidities that really are the reason why the NHS is falling apart and it seems no-one is accountable for it.
With public money and large scale organisations it's clearly just a cycle of feeding at the trough because as demand goes up agencies will just increase their charging rates. If the NHS is desperate then they know they'll pay it, it's easy money. In your example of £5k for a doctor to cover a single shift, what's that, 12hrs at £420ph??? It's just completely mental and that rate is well into footballer wage territory which shows how much these agencies are clawing in.
It's the same at my place though. I work for a very large UK company and our local management wanted to build a shower area in the toilets for cyclists in our office. They were quoted £10,000 for something that should cost say £1,000 at best? I'd of told them to get stuffed but it seems no-one did given the shower got fitted.
The NHS is no different, it will be paying costs which to most of us are quite simply unbelievable. And there are some people who refuse to examine these practices and just believe that we should pump unlimited money into it? It's completely mad.