Especially for those who haven't experienced it, it's a hard thing to respond to. Everyone wants to be a supportive friend, and say the right thing. Unfortunately, even with the best of intentions, the wrong words can be more hurtful than doing nothing at all. Questions, suggesting adoption, or saying anything God's plan, said at the wrong time are salt in a very open wound. The one thing that is appropriate to say when a loved one is facing loss or infertility is very simple.
"I love you, and I'm so sorry."
Let your loved one lead the conversation from there. There maybe other ways that you can help, but take your cues from your friend. What he or she needs more than words is a listening ear and your support. Less is more, here, and by exercising restraint in your response, you can still strengthen them as they face the challenges of infertility and loss.