Should we divide the question into two?
Are they guilty?
Do they deserve punishment or what punishment should they get if they do deserve it?
The answer to the first question then becomes fairly simple, it's yes.
So, someone commits a serious crime but is not apprehended.
Thirty years later his involvement in the crime becomes apparent but he is now demented. He has no recollection of having committed the crime - in fact he has little understanding of his own identity or what is happening around him. The evidence shows that he is clearly solely and wholly responsible for the crime. At the point of arrest the evidence shows that, if tried, he will be found guilty. However, his mental state shows that he will have no understanding of what that means.
Should he undergo trial in a criminal court for the sake of satisfying a "public need" or should it be accepted that any trial would be merely some kind of expensive public entertainment?
The answer to the second is more complex and probably varies on a case by case basis. In the case of Greville Janner, I don't believe anything would have been achieved by giving him any kind of punishment if he had been found guilty. However, consider the case where somebody drinks a bottle of whisky and tis stopped for drunk driving. What if they wake up the next day in a police cell with no memory of the events of the night before. Are we really going to let them off?
Your drunk driving argument does not exist.
The individual concerned - even if he has no recollection of the events - knows that driving with a blood-alcohol concentration greater than a specified level is unlawful. He will be presented with evidence of his misbehaviour and he will understand the connection between drinking whisky and the charges he is facing. He will be aware that the responses of the police and legal authorities are reasonable in the circumstances and (if he is wise) plead guilty.
The primary purpose of any trial (in the English Law jurisdiction) is to present the accused with a challenge and to provide the accused with the opportunity to respond to the challenge. If the accused is incapable of any response then, surely, there cannot be a trial.