Pay for prevention now, or pay for detention later
It just makes sense. Lock up a kid with other delinquents, not much good will come of it. Charles Dickens wrote at length about the destructive effects of prisons (called bridewells in Victorian England), workhouses and debtors prisons. In the same era, journalist Henry Mayhew documented that institutions for the poor and criminal were better at teaching crime than reforming. The notion of “schools for crime” is nothing new.
When the youth is released they often get into trouble again, using the knowledge gained in juvie and turnstiles back in.