Asalaamu alaykum and thank you for your question, sister,
Truly, it hurt my heart to read your question. I cannot imagine the pain and frustration you must be feeling. I, myself, have been blessed with far too much in the way of fertility and cannot say I have ever had to beg Allah for children. On the contrary, I have to beg Him to hold off on giving us more.
The Core Issue
The first thing I want to address if the heartbreaking comment you actually made at the very end of the question:
Will it make me a good Muslim to give my husband the divorce he wants since I am denying his right to have kids?
My dear sister, this is very untrue. You are NOT denying him the “right” to have children. This is the qadr of Allah, and it is not in your hands, not in the least.
You have not chosen this path, Allah has decreed this for you.
You were not created for the sole purpose of procreating, and I should hope your family and your husband are able to see the wonderful benefits you bring to this world beyond the “responsibility” to have children.
Not being able to give your husband children is not a grounds for divorce, not by any stretch. You did not enter this marriage as a breeding sow, and it hurts to think that is how you’ll allow yourself to be discarded.
Your worth lies in your creation of Allah, not in producing children.
The Questions
In regards your actual questions, I want to caution you to seek a second medical opinion. 39 is early for menopause barring extenuating circumstances. The normal age range for the onset of menopause is between 48-55, so you are still 10 years away from that. I would advise you to seek a second opinion before giving up hope.
Regarding making dua to Allah to help you in this affair, to give you children when you’re “medically unable”, I say absolutely!
God has all the power, and He has certainly done crazier things than giving women children when they were medically unable.
Look at the case of Elizabeth, the cousin of Maryam, the mother of Jesus. She became pregnant with Prophet Yahya very very late in life!
Look at the case of Ibraheem and his wife Hagar. He was a very old man!
We should seek Allah’s help in all things. It can never, ever be said that dua is wrong or unlawful, except in the case of seeking the destruction of someone who does not deserve such dua, and Allah knows best.
I advise you and your husband to consider that there are other routes to solve this problem than divorce and casting you off from the marriage and family.
Seek a second medical opinion. If this also confirms you are somehow in early menopause, consult other doctors to see about options. Consider adoption as a route to raise children together. At the very least, consider polygyny as an option if he insists on having his own offspring.
At the end of the day, if this man believes you are only a good wife for him if you are able to provide children, and feels you are easily replaceable if you cannot, by no choice of your own, divorce may actually be the best option for you!
May Allah make things easier for you, my sister, and ease your burden.
http://aboutislam.net/family-society/husbands-wives/infertile-couples-childless-doesnt-mean-hopeless/
http://aboutislam.net/counseling/ask-the-counselor/want-to-get-married/cant-get-married-as-i-cant-have-children/