Ok, let's begin from the other end. What evolutionary benefit does grief have in humans?
Nor is it safe to assume that any existing trait must confer an evolutionary benefit. Evolution isn't a perfect optimizer, and it's an ongoing process without a terminus. All kinds of traits in the current human population might turn out to be evolutionarily disadvantageous and scheduled for elimination via natural selection in the long run. We won't be around to find out.
But attachment has immense benefit for social animals. Attachment is maintained by both positive and negative emotional incentives.
Grief is the negative emotional incentive ramped up to the max.