Vulnerable children locked up and ‘gravely damaged by the state’, England’s former top family judge warns