The sun represents light and truth. However, in this play, deception is a central theme. All the truths are hidden by the characters, who manipulate, hide and use subterfuge. They must pay the consequences for this.
The main conflict of this play stems from the fact that Mrs. Alving feels remorse for her part in helping to deceive the world about what sort of man Captain Alving was. She feels that she should have told the truth to Oswald long ago. If she had been honest with him all along, the disease that he inherited from his father may still have been unavoidable, but she could have saved him the confusion that he felt upon finding out that his father, who he thought was morally pure, had syphilis. His own character might have been less cynical if the truth about his father had not come as such a shock.
Oswald's last words are "the sun" in recognition of what he has missed and avoided throughout his life.