All perfect praise be to Allah, The Lord of the Worlds. I testify that none is worthy of worship except Allah and that Muhammad is His slave and messenger.
We will give a summarized answer for your question. The person who obtains ill-gotten earnings must get rid of them by giving them out to the poor and needy.
Shaykh Ibn Taymiyyah said: "When a Muslim sells alcoholic drinks, the earnings are unlawful for him … rather, those earnings should be spent on the public interests of the Muslims, just as stated regarding the wages of a prostitute … and the like of it of compensation paid for unlawful goods or services.” [End of quote]
Such ill-gotten wealth is also unlawful for the heirs after the owner's death according to the preponderant scholarly opinion in this regard.
The Maaliki scholar Ibn Rushd said: “As for inheritance, it does not render unlawful money permissible to use. This is the correct scholarly opinion deduced from close scrutiny of relevant evidence …” [Al-Muqaddimaat]
If this person gifted his unlawful wealth to another person who is aware of the nature of such wealth, then according to the correct opinion, it is impermissible for the recipient to avail himself of it. If, however, he is among the Sharee’ah-set channels to whom unlawful earnings may be paid, such as the poor and needy, it is lawful for him to use it. Moreover, a person who has possession of unlawful wealth is not permitted to avail himself or his family of it unless he is poor and in need of it.
An-Nawawi said: “If he gives it – the ill-gotten money – to the poor, then this money is not unlawful for the poor; rather, it is lawful (for them). He may also offer it in charity to himself and his children if he is poor, because if his children are poor, they are eligible to receive such money. In fact, they have the priority in receiving his charity, and he himself may avail of that money in proportion to his need because he is also poor.” [Al-Majmoo‘]
For more benefit on ill-gotten money, please refer to Fataawa 374620 and 198785.
Allah Knows best.