א"ר יצחק מפני מה היו אבותינו עקורים מפני שהקב"ה מתאוה לתפלתן של צדיקים
Says R' Yitzchak: Why were our forefathers sterile? Because HaShem desires the prayers of the righteous.
From Yevamos 64a
The picture this Gemara paints is a pretty bleak one. It almost sounds like HaShem has some insecurities and takes it out on the righteous. "I just love those tefillos. Hm, I'm not getting enough of them. Why don't I just slap these puny little humans around until they give me what I want?"
Obviously this cannot be the case. HaShem is not a cruel G-d, and He created this world only to bestow good on us. So what does this metaphor mean, that HaShem punishes the righteous so that they'll daven?
(This is not asking what it means that HaShem wants or needs our tefillos. I'm asking what it means that HaShem punishes so that they'll daven, which seems to be a cruel and unusual punishment for a crime left uncommitted.)