The Torah recounts for us how the plagues have reached the climax and all the first-borns of Egypt are being smitten. The text of the verse tells us, From the first born of Par'oh sitting on his throne, until the first born of the captive sitting in the pit [jail] etc.".
Why did the first born of the hostages need to be smitten along with the Egyptians? They were in the same boat, more or less, as the Hebrews! What did they do to deserve punishment?
Rashi explains that they had rejoiced in the torture of the Jews. For that they deserved punishment.
We know that God has to punish us for our wrongdoings. That punishment has to be meted out by someone, somehow. The Egyptians were chosen, for whatever reasons, as th eones who would mete out the punishment to the children of Jacob. They went at it with a vigor and went beyond the call of duty that was necessary and therefore they deserved punishment, for their harshness towards the Jews. The children of the captives had no obligation to be involved, yet instead of commiserating with their fellow hostages and feeling their pain, theuy rejoiced in the torture they saw the Jews receiving. Therefore they were punished. They were guilty by attitude.
We must keep our attitudes in check and understand when is appropriate for different emotions to manifest themselves. There is a time for rejoicing and a time for depression. A time for happiness and a time for anger. If you have the right attitude of objectivity, you can empathize properly and display the appropriate emotion.