The Death Ray (formerly the stun ray) was a ray gun designed to kill people, using short red blasts; it was presumably powered by Wonderflonium. Dr. Horrible eventually created one from a modified Stun Ray, in an event which marked the beginning of his descent into evil. Dr. Horrible fired it several times successfully in the air to frighten his audience at the unveiling of a statue of Captain Hammer. It was forcibly taken from Horrible by Captain Hammer who turned it on him. In the process of taking the Death Ray it got damaged and so when Hammer tried to kill Horrible with it, it malfunctioned, instantly exploding into pieces. A piece of shrapnel from the exploding Death Ray impaled Penny in the stomach, resulting in her death.
Another theory is that Dr, Horrible might have put a safeguard into the gun so others couldn't use it, and that is why it exploded when Captian Hammer tried to fire it.
There is also an existing theory that the death ray exploded as a result of the Wonderflonium powering the Death Ray being bounced.