In the story’s era it should have been the wife that gets replaced or the husband will take in another wife and not the wife getting impregnated by a random man. lol.
I think it could happen if the husband is too poor to get another wife. I believe the husband usually asks for his brother or male relative, not a stranger.
It wouldn't make a difference if he's the one with the fertility problem, as the story states. It would be even more obvious if he took a second bride and failed again to father children again.
In the story’s era it should have been the wife that gets replaced or the husband will take in another wife and not the wife getting impregnated by a random man. lol.