There is a difference between reveling in the fact that someone has committed a logical or moral error, even to the point of happiness or excitement that they have faltered so that one has a reason to pounce on them, and joyfully welcoming how, among other things, an amoral life setback makes it more difficult for them to wreak wicked havoc on others. Obviously, the first kind of reveling is itself irrational and (if there is good and evil) immoral, since no one can ever legitimately err in such ways to in turn legitimize this reaction in another person.
What if the reveler does not stumble into the pitfall of this sort of celebration? If someone is evil, would it be correct or at least permissible to delight in their trials and pain because of their faults, instead of in how they are/were in the wrong as if to celebrate stupidity and wickedness? Not according to Proverbs. What might seem like a random topic of little direct emphasis within Biblical theology comes up more than once in pivotal ways. In spite of its reputation as a set of texts with no place for restraint from brutality or for compassion, the Old Testament is far from evasive on this point:
Proverbs 24:17-18—"Do not gloat when your enemy falls; when they stumble, do not let your heart rejoice, or the Lord will see and disapprove and turn his wrath away from them."
Listing various sins he claims to have not practiced out in the open or in secret, Job brings up the sin of gloating over an enemy's misfortune. Along with evils like denying justice to his male and female servants (31:13-15), neglecting the poor and vulnerable (31:16-22), and worshiping or erroneously exalting wealth or the cosmos (31:23-28), expressing a belittling sort of pleasure at the downfall of an enemy is a sin that he specifically distances himself from.
As seen from Proverbs, this is not the mere perception of Job, since rejoicing in the calamity of an enemy is clearly condemned as antithetical to God's character outside of a narrative like the book of Job. The assumption made by some Jews and Christians is that whatever a figure like Job or Paul says about ethics in a Biblical story must be accurate, but this would only have to be the case if it aligns with God's nature. Sometimes what an otherwise righteous Biblical figure states or does is not said to have divine approval, or it clearly contradicts what God demands elsewhere. Still, what Job says is consistent with Proverbs 24:17-18.
Job 31:29-30—"'If I have rejoiced at my enemy's misfortune or gloated over the trouble that came to him—I have not allowed myself to sin by invoking a curse against their life . . .'"
Job insists he has not committed two independent but similar sins: rejoicing at the trouble of his enemy and cursing them. Cursing any person is evil [1], with some instances being far worse than others (Exodus 21:17, Leviticus 20:9). Each of these sins disregards the value of each person by harming them in some unjust manner. In fact, the two can go hand in hand. Cursing humans is actually singled out as depraved for the same basic reason as murder (compare James 3:9 with Genesis 9:6).
And the similar sin of gloating over misfortune is something promised significant judgment later in the Bible. On the scale of a collective civilization, God predicts defeat and death for the Ammonites in Ezekiel 25 precisely for being joyful at the tragedy that befell Israel and Judah, which came about because God removed his protection from them after his people, as a whole, persisted in sin. Indeed, beyond withholding further calamity from Israel, God reacts harshly to the Ammonites to the point of allowing them to be conquered. The Bible, in saying these things, yet again gives specific examples of how Gentiles do not just have a pathetic and woefully incomplete seven moral obligations as opposed to Jews (Rabbinic Judaism's Noahide Laws are very clearly logically and Biblically false). Both gloating and malice are utterly condemned no matter who is on either end:
Ezekiel 25:1-4, 6-7—"The word of the Lord came to me: 'Son of man, set your face against the Ammonites and prophesy against them. Say to them, "Hear the word of the Sovereign Lord. This is what the Sovereign Lord says: Because you said 'Aha!' over my sanctuary when it was desecrated and over the land of Israel when it was laid waste and over the people of Judah when they went into exile, therefore I am going to give you to the people of the East as a possession . . . For this is what the Sovereign Lord says: Because you have clapped your hands and stamped your feet, rejoicing with all the malice of your heart against the land of Israel, therefore I will stretch out my hand against you and give you as plunder to the nations. I will wipe you out from the nations and exterminate you from the countries . . ."
Despite the lack of a statement like "You must never gloat over an enemy in their distress" in Mosaic Law, God is crucially not acting beyond or contrary to it in affirming the evil of such belittling attitudes or words in Ezekiel 25. The Law does mandate that one take measures to assist one's enemy when they are in immediate need, such as when their beast of burden collapses under a load. For the sake of both the animal and the human, who is one's enemy, one should intervene to offer assistance (Exodus 23:4-5), which excludes an apathetic or sadistic gloating from the sidelines. However, Yahweh's laws never go so far as to condemn being an enemy to another party or having personal enemies.
Even in the midst of extreme and borderline misleading exaggeration as he addresses divorce [2] and oaths, Jesus, assumed by many to prescribe an ultimately quite unbiblical degree of aversion to conflict, does not say it is evil to have enemies. Instead, one is to love one's enemies and not only one's friends or allies (Matthew 5:44-45), as they too are humans made in God's image with the same rights as all other people. Nothing about loving enemies and treating them like a human goes beyond what the Law dictates, so there is no asinine, arbitrary addition or "correction" to it here as would be the case with many Pharisaical or evangelical ideas and even with some of the other ideas Jesus seems to propose. No matter where one looks in the Bible, having enemies on the basis of their ideological or behavioral misalignment with the truth is not declared wicked.
It could only be rational and righteous to be opposed to the wicked on the basis of their wickedness, after all. But treating them in certain ways is always sinful. Although it is possible to celebrate that a wicked person has lost power and thus has a lesser capacity to do evil from a distance without directly interacting with them, taunting them or in almost any way celebrating the fact that a human is suffering (not at justice being imposed as in the case of something like Deuteronomy 25:1-3, which does require some suffering) remains a despicable immorality.
God does not take pleasure at the death of those who deserve to die, as much as their life ending is a positive thing in some regards (Ezekiel 18:23, 33:11). He likewise does not take pleasure at the suffering of humans as if them being in anguish is ever left to itself the morally positive thing. Even in the limited instances where the likes of physical lashings and executions are obligatory within certain inflexible boundaries, it is always a travesty that there is any sin to punish in the first place.
This should never be made the subject of delight, nor should the human whose objective value does not disappear no matter the folly of their stances or actions ever be denigrated. Living this out can be very difficult for those with a proclivity towards anger or coldness. Yet mockery of stupid, evil people is not even inherently the culprit, depending on how it is done (for instance, see Psalm 2:1-4). Celebration of a person's ruin or that there is a need for the wicked to come to ruin is.
[2]. See here for elaboration, for instance: