Death might just be the original bad guy, the dark power par excellence, and it certainly puts on quite a show in this novella. From the moment he gets sick, Ivan is locked in a life-or-death struggle with, well, Death. Death comes to haunt him at every moment, making it impossible for him to enjoy any aspect of life or go on living as he did before. It makes him bitter and depressed, and fills him with even more hatred of his family than usual. It even gets called "It" and does things like visit Ivan in the courtroom and stare him in the face in the midst of his proceedings (metaphorically, of course). Ultimately, It makes him despair and feel that life is pointless and horrible.
Technically it's hard to separate Ivan's illness (which is what's killing him) from death. But what Ivan feels to be confronting him is death itself, rather than his illness. And besides, Death makes for a much better bad guy than a malfunctioning appendix.
Wait, didn't we just say death was the bad guy? Yeah, we did. But at the end of the story – those last four weeks, and those last three days in particular – Ivan's struggle shifts from a struggle against death to a struggle against himself, or rather, his past life. What Ivan's wrestling with is the recognition that his whole life has been lived wrongly. That's what he refuses to accept, and what causes him so much torment. The moment he sees the light he accepts it, and suddenly death is no longer even an issue.
So why does Ivan say, "Death is finished"? Doesn't that make it sound like the bad guy he's just beaten is Death? Yes, but we've got to ask what death really means. If Ivan proclaims that "Death is finished" just as he dies – and the narrator tells us that "in place of death there was light" (12.14) – then Ivan's bodily death doesn't seem to be what he means by death. Part of what he means is the fear of death, and that's clearly gone. But more likely what he's talking about is the death of his soul. All his life since his childhood Ivan's life has been false, and meaningless. Ivan has been trapped in a kind of living death, because his soul hasn't been alive. To Ivan in his false life, bodily death seemed like the enemy. But when Ivan sees the light, it's revealed that his false life was the real enemy all along.