There is no wrong in adopting fair means for having children while it is disallowed to adopt unlawful means. It is not right to masturbate in order to get children by artificial insemination; however the child born out of husband?s semen will be regarded ?Sabit-un-nasab? (one?s own descendant), but this way is unnatural and undesirable. It is when the husband himself inserts the semen into the uterus of his wife, otherwise it is haram to get it done by any doctor; since covering of private parts is obligatory and it is haram for other men to see the private parts of a woman without any Sharai (prescribed by Shariah) reason. The husband and wife should avoid it.
Allah (Subhana Wa Ta’ala) knows Best
Darul Uloom Deoband