Where does "personhood" come from?
The plight of Dobby the house elf can serve to illustrate the common attitudes around this sensitive question. Dobby was the house elf who "belonged" to the Malfoy family. As such, he was treated poorly - even abused - because as a house elf, his value was only seen in his utility to the family. He was inhuman, unworthy of affection and totally disassociated with any sense of dignity. We see this in his surprise at how well Harry treats him in speaking with him at their first meeting and in Hermione's care and concern for the ordeal of the other elves.
The Malfoy's rejection of Dobby's dignity is akin to a societal prejudice against those who count for nothing - the poorest, the "rejects," the prisoners, the elderly, the unborn. Their personhood is often seen as an inconvenience, rather than an inherent part of their being. An unborn child is a "fetus" until a parent ascribes a value to it as a child who is "wanted." A man in a nursing home or hospital is seen more as a patient occupying a bed, rather than a person with infinite beauty and worth. A prisoner is seen first as a miscreant who has lost all claim to the dreams of any man, rather than a soul marked still by the touch of God.
Harry provides a "salvific" role for Dobby by providing a way out of his servitude. He always saw Dobby as an individual of worth, and at last, in the end, he is able to die "a free elf." Personhood is not a matter of "desert" or "earning it." Rather, it comes from the gift of God, freely given, for no other reason than His infinite love.