In his book “Ajwibat al-Istiftaat” modern leader of shia Iran and shia Islamic revolution, was asked, and he answered:
Q. Is it permissible for a woman, whose husband is sterile, to be artificiallyinseminated with sperm from a stranger man (other than her husband), i.e., through placing the sperm in her womb?
A. In itself there is no legal impediment to inseminating a woman with the sperm of a non-mahram man. However, it is obligatory to avoid the preliminary steps which are harām, such as looking and touching. However, the born child in this way does not belong to the husband of the woman, rather to the person who donated the sperm and the woman whose egg and womb were used in the process.
We all know, that in Islam and everywhere else, child would be accepted as legitimate, if he was born from man and woman which are in nikah.
What would be ruling upon a child, which born from man and woman, which are not married? Illegitimate – bastard.