A federal judge in California has ordered the Trump administration to temporarily restore legal aid to tens of thousands of migrant children who are in the United States without a parent or guardian.