'Why is this man in prison?', judge asks government lawyer in immigration detention case