The father and mother of a child are the joint legal guardians of their child, and the rights duties of each parent is equal. When one parent dies, the survivor becomes the sole guardian.
If a 3rdparty (like a grandparent) wishes to become the guardian of a child, against the wishes of the parent, they must prove that the best interests of the child require substitution or supplementation of parental care and supervision to provide for the essential physical and safety needs of the child or to prevent specific, significant psychological harm to the child.
See RSA 463:1- 463:32. (statutes governing the guardianship of the person and estate of a minor)