Legal guardian
Sometimes a parent will write a will, which explains their last wishes in case they die.  In the will, they can say who they want to take care of their child if the parent dies.  If the parent dies, a court still has to approve the person named in the will as the child's new guardian.  The new guardian does not have to be a blood relative of the parent or child.