This part of the poem "Barbie Doll" by Marge Piercy can be found in the last stanza, where it says:
In the casket displayed on satin she lay
with the undertaker's cosmetics painted on,
a turned-up putty nose,
dressed in a pink and white nightie.
Doesn't she look pretty? everyone said.
Consummation at last.
To every woman a happy ending.
When the "girlchild" (who represents every girl and woman) was alive, she was told that she possessed intelligence, a strong back, a good dexterity with her hands, and a high sexual passion. However, none of those important factors for being a happy woman matter to society. What matters to the society to which the poem refers is the superficiality of womanhood: The looks, the pose, the fake mannerisms, in all, the fantasy of being a woman.
To answer your question, this is the reason why the girlchild has to die in order to be accepted by others: Once the girlchild gives up trying to be a real, natural woman, she dies. Yet, the undertaker makes her into that ideal-looking fake woman society wants her to be. Once in her casket, she looks like they like. She has to be dead and give up her real aspect of womanhood in order to satisfy a society that lives in oblivion as to what women are really like, what they need, and how they should be treated.
The poem, "Barbie Doll", written by Marge Piercy, is a critical commentary about the injustice of comparing a real, imperfect woman to an idealized, perfect version. In lines 22 and 23 of the poem, "Doesn't she look pretty? everyone said. Consummation at last.", the deceased woman has finally achieved the admiration she desired during her lifetime. This admiration from the funeral goers however is shallow and only based on how the undertaker has presented her. The poet is concerned about society's failure to celebrate the genuine inner beauty and complexity that all women possess. The last line of the poem, "To every woman a happy ending.", is meant to be ironic because a truly happy ending will be when women are no longer objectified by society.