Reminder that Lain is, "program" or not, still a young kid and knowing your entire life was a lie is just devastating. It's perfectly reasonable why she becomes so detached afterwards..
The second-to-last episode.
Lain: I'm so sorry... I just mess up everything for you. (Cue Reset Button)
The ending, the world is essentially better...because Lain erased herself from existence.
Lain talking to her father in the last episode, and the first time the usually stone-faced Lain just..breaks and begins to cry.
Consider episode 12 from Alice's perspective. She knows presumably little of the conspiracy and technology that Lain has been investigating - all she knows is that she's seen her best friend behaving very strangely and oftentimes contradictory. She goes to Lain's house only to find that Lain's family is gone other than Mika, who's practically braindead, and a thick fog covers the entire inside. She finds Lain in her room, and Lain begins talking about the wired and the human consciousness and everything else discussed over the course of the series, and Alice is completely terrified, having no reason to believe anything is going on other than Lain is extremely mentally ill, but because Lain is her best friend, she calms Lain down with her heartbeat. They talk and laugh and everything's going fine, Lain has calmed down and is acting like a normal person. Then she starts talking to God.
Episode 13 makes it worse: Despite Lain doing everything to protect her, Alice is just horrified of her and even slaps Lain because she is terrified of her. Is there any wonder Lain hits the Despair Event Horizon and decides to reset everything?
The Bittersweet Ending: Lain accepts Godhood, but had to Ret-Gone herself out of existence to let her family and friends live happy lives. The only happy ending of it is she watches over Alice, who now has grown up to be a happy woman, leaving her with a comfort that she and Alice truly will meet again.