A federal appeals court had found the policy illegal, saying migrants subjected to it “risk substantial harm” and “even death.”