Praise be to Allah.
Eating from haraam earnings is a sin, and a stern warning was narrated from the Prophet (blessings and peace of Allah be upon him) for the one who does that, as he (blessings and peace of Allah be upon him) said: “No flesh grows that was nourished by that which is unlawful but the Fire is more appropriate for it.” Narrated by at-Tirmidhi (558); classed as saheeh by al-Albaani.
The scholars have stated that knowledge of what is halaal and haraam is one of the most important matters of faith. Al-‘Allaamah ar-Ramli (may Allah have mercy on him) said in Nihaayat al-Muhtaaj (8/150): Knowledge of these matters (i.e., halaal and haraam) is one of the most important matters of faith, because knowledge of halaal and haraam is an individual obligation (fard ‘ayn), and a stern warning has been narrated against the one who eats from haraam earnings. End quote.
The Prophet (blessings and peace of Allah be upon him) stated that eating from haraam earnings is one of the things that prevent du‘aa’s and righteous deeds from being accepted. In Saheeh Muslim (1686) it is narrated that Abu Hurayrah (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “O people, verily Allah is Good and does not accept anything but that which is good. Allah has enjoined upon the believers that which He enjoined upon the Messengers, as He says: ‘O messengers, eat from the good foods and work righteousness. Indeed, I, of what you do, am Knowing’ [al-Mu’mineen 23:51] and ‘O you who have believed, eat from the good things which We have provided for you’ [al-Baqarah 2:172].” Then he mentioned a man who has travelled on a long journey and is dishevelled and covered with dust; he stretches forth his hands to the heaven, (saying) “O Lord, O Lord”, but his food is haraam (from haraam earnings), his drink is haraam, his clothing is haraam, he grew up nourished from haraam earning, so how can his du’aa’ be accepted?”
Al-‘Allaamah Ibn Rajab al-Hanbali (may Allah have mercy on him) said in Jaami‘ al-‘Uloom wa’l-Hikam (1/260): What is meant by that is that the Messengers and their nations are enjoined to eat of good things, i.e., from halaal earnings, and to do righteous deeds. So long as one’s food is from halaal earnings, then righteous deeds will be accepted, but if the food is not from halaal earnings, then how can the deeds be accepted? What is mentioned after that about du‘aa’ and how can it be accepted when one is eating from haraam earnings is simply to highlight how unlikely it is that good deeds will be accepted when one is nourished from haraam earnings. End quote.
So the Muslim must fear Allah, may He be exalted, with regard to his earnings, his food and his drink; he should take what is halaal and refrain from what is haraam.