In Islam, the relationship between the husband and wife should be based on mercy, compassion, and mutual respect. Part of that mercy is that the husband should not order his wife to do anything that might contradict the teachings of Islam whether that is done during his life or even after his death, which is actually the case in point.
Dr. Rif`at Fawzi, former professor of Shari`ah at Cairo University states: In Islam, the husband is not allowed to order his wife to do anything that violates the rules of the Shari`ah, even after his death. The wife is not obliged to abide by such a condition prescribed by the husband. After the death of the husband the wife is permitted to marry whomever she wishes after the `iddah (waiting period) has finished.
Having said this, I should stress here that if during his life the husband recommends a certain person for his wife to marry in case of his death, and it happens that the person recommended by the husband during his life proposes to the woman after her husband’s death, then in this case there is no harm in the woman marrying him if she agrees to. Woman’s marriage, in this case, will be based on freedom of choice and not based on the recommendation given by the husband before his death. The difference between the two cases is clear.