Praise be to Allah, and may peace and blessings be upon the Messenger of Allah. To proceed:
The basic principle in Islam is the prohibition of pessimism and believing in bad omens, and believing that something independently brings benefit or harm. The Prophet ﷺ said: “There is no contagious disease and no bad omen, and I like good omens.” He ﷺ also said: “Believing in bad omens is shirk.”
It is authentically reported that he ﷺ said: “Bad omens are in women, houses, and horses.” Another narration states: “If there is bad omen in anything, then it is in the house, the woman, and the horse.”
This does not mean that every woman, every house, or every horse contains evil, or that any of them independently causes misfortune or harm. This would contradict the prohibition against believing in bad omens. Nothing has an independent effect except by the permission of Allah, the Exalted.
Scholars have interpreted the hadith in several ways. Among them is that Allah, the Exalted, may place in some things causes of harm or hardship. A woman may have a bad character, a house may have bad neighbors or be a source of frequent harm, or a horse may be of no benefit to its owner. In such cases, getting rid of it is permissible if keeping it results in harm or hardship.
Some scholars have also mentioned that bad fortune may affect the person who believes in bad omens and gives in to superstition, because believing in omens weakens reliance upon Allah. Allah may allow a person's pessimistic attitude to become a cause of what he dislikes, whereas the believer relies upon Allah and does not allow illusions and superstitions to control his decisions.
Therefore, if a person finds genuine harm in a woman, a house, or an animal, he may leave her, leave it, or sell it in order to prevent harm, not because he believes that it independently causes harm. This is taking lawful means to prevent harm, and it is not the prohibited practice of believing in omens.
As for merely believing that marrying a particular woman, living in a particular house, or owning a particular animal brings bad luck simply because of its association with him, without any valid reason, this is the prohibited practice of superstition and pessimism.
In conclusion: The hadith does not mean that a woman, a house, or a horse is inherently evil, nor that any of them possesses the power to bring benefit or harm. Rather, there may be actual harm or hardship in some of these things by Allah’s decree, in which case a person may legitimately remove the harm and distance himself from its cause without falling into superstition.
If a believer finds some feeling of pessimism in himself, he should repel it by relying upon Allah and say:
“O Allah, there is no good except Your good, there is no omen except Your omen, and there is no deity besides You.”
And Allah knows best.