Is it permissible to buy the house that was bequeathed to some of the heirs and not others without their consent?
What this person did is invalid and is haraam for two reasons:
1.He made a bequest to some of his heirs, and a bequest made to an heir is not valid and should not be executed, unless the rest of the heirs agree to that.
It was narrated that Abu Umaamah (may Allah be pleased with him) said: I heard the Messenger of Allah (blessings and peace of Allah be upon him) say: “Allah has given each person who has rights his rights, and there is no bequest for an heir.” Narrated by Abu Dawood (2870), at-Tirmidhi (2120), an-Nasaa’i (4641), Ibn Maajah (2713); classed as saheeh by al-Albaani in Saheeh Abi Dawood.
Ibn ‘Abd al-Barr (may Allah have mercy on him) said: The scholars are unanimously agreed that there is no bequest for an heir and this is their ruling, based on their definitive opinion that this hadeeth is sound.
End quote from al-Istidhkaar, 7/245
2.He did not treat his sons fairly in terms of giving; the Prophet (blessings and peace of Allah be upon him) described such actions as injustice and refused to bear witness to that.
See the answer to question no. 153207
Allah, may He be exalted, explained to His slaves the basic rulings on inheritance, then He warned those who go against His rulings and overstep the limits He has set, as He says (interpretation of the meaning):
“These are the limits (set by) Allah (or ordainments as regards laws of inheritance), and whosoever obeys Allah and His Messenger (Muhammad SAW) will be admitted to Gardens under which rivers flow (in Paradise), to abide therein, and that will be the great success.
And whosoever disobeys Allah and His Messenger (Muhammad SAW), and transgresses His limits, He will cast him into the Fire, to abide therein; and he shall have a disgraceful torment”
Once that is established, (it becomes clear that) this bequest was invalid, and that which is invalid cannot be implemented, because the Prophet (blessings and peace of Allah be upon him) said: “Whoever does an action that is not in accordance with this matter of ours will have it rejected.” Narrated by Muslim (1718).
Based on that, what the one to whom this bequest was made must do is return the bequest to the estate and divide it along with the rest of the estate in accordance with the shares ordained by Allah, may He be exalted.
Al-Baaji (may Allah have mercy on him) said: The words “There is no bequest to an heir unless the other heirs agree” mean that the bequest is invalid if the other heirs object. If a person made a bequest to an heir and did not make any other bequest, and the heirs want to reject that bequest, then he [the deceased] is like one who did not make any bequest and the heirs should divide the estate in accordance with the laws of inheritance.
End quote from Sharh al-Muwatta’, 4/83
One of the conditions of a transaction being valid is that the item sold should be the property of the seller. The ownership that is based on the bequest mentioned is illegitimate and invalid ownership, so this bequest cannot be the basis of ownership, and it is not valid to sell it or buy it or give it, because that is based on transgression and its owner – the beneficiary of the bequest – has usurped the rights of the other heirs. The Prophet (blessings and peace of Allah be upon him) said: “that which is unlawfully planted confers no rights”. Narrated by Abu Dawood (3073) and at-Tirmidhi (1378); classed as saheeh by Shaykh al-Albaani.
Al-Hajaawi (may Allah have mercy on him) said: The dealings of the usurper are invalid.
It says in Fataawa al-Lajnah ad-Daa’imah, 13/82: If a person is certain that the product offered for sale is stolen or is usurped, or that the one who is offering it for sale does not have legitimate ownership of it and is not acting on behalf of its owner in selling it, then it is haraam for him to buy it, because buying it comes under the heading of cooperating in sin and transgression, and in depriving the real owner of his property, and because that involves wronging people, approving of evil and having a share of the sin. Allah, may He be exalted, says (interpretation of the meaning):
“Help you one another in Al‑Birr and At‑Taqwa (virtue, righteousness and piety); but do not help one another in sin and transgression”
And Allah knows best.