> But what should we do when rehabilitation repeatedly fails for a particular individual?
Bit of the UK currently have a persistent prolific offender strategy. There's no national clear definition of a PPO, but there are estimated to be about 8,000 nationally. (In a country of about 70m). I've seen estimates that about half these people are in prison. (One old definition of a PPO was someone over 18 who is convicted of 6 or more recordable offences in the past 12 months. But that definition is old, and people now look at the impact to the local community rather than number of crimes.)
The PPO strategy has several layers.
Offenders are identified, and provided with large amounts of support to rehabilitate. This includes education, housing support, drug and alcohol treatment, and so on. (I don't know whether it looks at undiagnosed brain injury, which are common in prisoners).
When they're in the community they are closely monitored. Any criminality is rapidly detected, prosecuted and convicted, and punishment is rapidly applied. Most of these people will be out of prison "on licence", which makes returning them to prison easier. This makes it very clear that criminal behaviour is not tolerated. Sometimes the justice system does not make that clear!
The aim is to reduce the amount of offending the person does, but also to reduce the fear of crime in the local community.