One of the most difficult things when a friend is grieving is knowing what to say, and what not to say. Here are some suggestions to help you. If your friend is expecting a baby with a poor prenatal diagnosis, see Supporting a Friend with a Poor Prenatal Diagnosis.
The first time you see a friend after she has lost her child, the best thing to do is simply to hug her and say, "I'm so sorry." There are really no other words that are suitable. Just your love and presence are the best things you can give.
But then they began to say things that didn't help at all. In fact, some of the things they said were quite hurtful. Learn what they did right and wrong in Job's Friends, and read the entire account of Job's grief and how he handled it.
Don't say things like "It's for the best," or "She's in a better place." While she indeed is in a better place, those things are like telling the parents that they should cheer up, that it's not so bad. Their loss is immense; grieve with them and honor their grief.
Don't say, "You can have another one." This was her child, not a goldfish that can be replaced. Another child will bring joy someday, but will never replace the one who is lost.
Don't say, "I know how you feel", unless, of course, you have been there, too.
Other things that are not helpful: any sentence that starts with the words "at least". At least she didn't suffer. At least you have your other kids. That is like saying, "look on the bright side" in a situation when there is no bright side.
Along the same lines, avoid the use of the word "Should". Grieving people feel so pressured about what is "proper" and what they "should" do. Don't add to it. There is no should in grief. Instead, ask her what she wants to do, or what she needs to do. And then encourage her to do it. Validate her feelings. Grieving people are the only ones who know what they really need.
Don't try to "fix" your friend. She isn't broken, she's just grieving! I know it is very difficult to watch someone hurt so badly. You just want to do something to take away the pain. But resist the urge to offer advice and try to fix things. You can't. She needs to feel the grief in order to heal. Just walk with her and listen - as often as she needs it.
Don't feel that you have to give an explanation for why this happened. Coming to peace with the "why" is a large part of the grieving process. But your friend has to do it herself, in her own time. Just listen, support, and encourage her as she works through those questions.
Don't say, "you're so strong" or "I could never handle it". First of all, the person doesn't want to be admired; she wants her child back. And secondly, what choice does she have? She is doing the best she can, just as you would. Those statements just add pressure - an expectation that strength is good and sad is bad.
It is also good to ask her, "how are you really doing?" But only ask if you have the time to listen to the answer. And if you are ready to hear things like "awful." It is difficult for a grieving person to answer those questions - and if you don't really want to hear the answer, they will soon realize that and will stop answering it. Give them the gift of your time and a listening ear.
A good thing to say is "you made it through the holiday" or "you made it through the event" or even "you made it through church". Recognizing the difficulty your friend is having in doing these seemingly simple things, and encouraging her for each victory, no matter how small, is very helpful. And "making it" simply means living through it. If she cried, fine. If she had to leave, fine. The point is, it's over, and she survived it. One step closer to healing. Encourage her in that.
Realize how difficult it is for your friend to hear about pregnancies and babies. And it will be for a long time. When those situations arise, acknowledge her difficulty and allow her to talk about it. That will really help.
Be patient. Grief is exhausting. Your friend will not be herself for some time. She will need to talk about her baby, her experience, her feelings - again and again. Will you be the one who will listen without judging, without trying to solve her problems? Will you be the one who supports her for months and even years? If you are, you will be giving the greatest gift you can in helping her heal, a gift she will appreciate for the rest of her life.