Tolstoy's message, in this story and in most of his later fiction, involves the transience and relatively unimportant nature of earthly life. Ivan Ilyich, in the agony of the final three days before he expires, senses that he has made some fundamental error in the way he's lived his life. This has been, simply, the fact that he, like most people, valued material things. The wrongness of living for possessions and not spiritual values is brought home more emphatically because Tolstoy stresses that Ivan Ilyich was not an unusual or a bad man: his life has been unremarkable, and therefore his fate is "all the more terrible."
Like many (if not most) people, Ivan Ilyich has had the implicit attitude that, somehow, death is not a reality for him. When he becomes ill, his reaction is that something inexplicable is happening to him, when the reality of the situation is that this—illness and death—will happen to everybody. In his case, it just occurs sooner and more rapidly. The principal theme of Tolstoy's novella is, arguably, that salvation consists of recognizing that death is in some way the only thing that has meaning and that earthly life is merely a kind of window dressing. This is what Ivan Ilyich learns in his final hours on earth.
The question remains as to why Tolstoy himself believed this. The implication of his late writings seems to be that the material world is meaningless just because it is impermanent. But ultimately, his view is based not so much on this fact as on his religious beliefs. Tolstoy believed that only way to secure happiness in the next life is to renounce the value of this life.