Here's my go at it. I haven't seen the show in a few years, but I think I remember the main plot points. Spoilers for the whole series:
[SPOILERS]
The show opens with Lain's classmate, Chisa, committing suicide at the urging of Masami Eiri.
Eiri had previously been an engineer on the technology foundational to the Wired, and he included special code to integrate his personality and memories into the network. This gave him unrestricted access to everything on the network. He set himself up as a god of the Wired, and conscripted the hacker group known as the Knights to serve him. His physical body committed suicide.
His goal, using the Knights as his tools, is to merge the Wired with the real world. Lain is the lynchpin to this plan, and he needs her to abandon her body and transfer her consciousness to the Wired (just as he and Chisa did) to accomplish this.
This raises the question of just what Lain is and why she's so essential. I don't know an easy way to describe this, and this ambiguity is pretty much the heart of the show. I'll give my thoughts at the bottom of this post, but let's just get back to the plot and remember that Eiri needs Lain to commit suicide.
He manipulates Chisa, one of Lain's classmates, into going first so she will urge Lain to join her. This event awakens Lain's interest in computers.
The Knights, partially on behalf of Eiri and partially for their own motivations, create a virtual duplicate/aspect of Lain and use it as a tool for furthering their goals of pushing the Wired into the real world. This duplicate is a feared hacker on the Wired and has at least some capacity to alter memories.
We also have keep in mind that "altering memories" is, in terms of Lain's setting, the same thing as altering reality itself. Whatever people remember to have happened is what actually happened. When Lain or the Knights do something impossible, what they're doing is probably better understood as altering human memories and perception to make that impossible thing happen. (It seems likely to me that the more Lain is reliant on the Wired, the more of this power the Knights have access to through the Lain duplicates.)
The Knights use this ability to perform strange pranks, such as creating a godlike image of Lain in the sky and merging data from the real world and several online games. Some of this is to forward their plan of raising consciousness of the Wired as something just as real as the offline world. This is something they see as philosophically true and, with Lain's help, literally true.
Opposing the Knights are the operatives of Tachibana Labs. These are Eiri's former employers and they continue to maintain the code running the Wired. They are aware of Eiri's scheme and would prefer if it were neutered. They are working to remove Eiri's code from the Wired, and the Men in Black keep Lain under observation. Eventually the Men in Black execute all the members of the Knights, but are betrayed by their employer, who seems to have wanted the Knights removed but is interested in the potential of Eiri's long-term goals.
Eiri has the same basic goal as the Knights, merging the Wired and the real world, but is more focused on Lain. He wants to impress upon Lain that she can rewrite memories/reality because people and their memories are constructs of data, just like the data on the Wired. The Wired is no different from the real world, except that the real world is a place where she suffers from loneliness and isolation, and the Wired is a place of friendship and power.
After introducing Lain to her potential, he strikes the biggest blow: He tries to get Alice to turn on Lain. Alice is the closest thing Lain has to a friend in the real world, and is likely the only person Lain truly cares about.
The Lain duplicate spreads personal rumors about Alice having a relationship with a teacher at their school. (These rumors are untrue, but they're particularly hurtful because Alice does have a serious crush on this teacher. I think later he's shown in a relationship with her when she's an adult.)
When the Lain duplicate's interference is revealed, Alice believes Lain has betrayed her trust and Lain is emotionally devastated. She awakens her latent potential to rewrite memories, and causes everyone to forget about the harmful rumors. Except Alice.
Alice quickly realizes something is wrong. She goes to Lain's house to confront her about the confusing situation, and discovers that Lain has been living in a horrible state. Her physical body has been completely neglected and her home has turned to ruin. (Lain's parents were revealed to be actors, hired either by Eiri or Tachibana Labs to care for her temporarily.) All this shows that Lain has grown to accept Eiri's philosophy: The physical form is meaningless.
At the last moment before Eiri's influence becomes complete and Lain transfers herself to the Wired (likely by committing suicide) Alice appears and manages to convince Lain otherwise. Their relationship has special meaning in their physical bodies, in a way they cannot explain but has sufficient value for Lain to reject Eiri's influence. She even points out that what Eiri is doing is likely something beyond his innate capacity - there must be someone behind Eiri, masterminding this plot without ever being recognized. There's been a true God behind this all along.
Enraged, Eiri manifests the power he has in the real world and attacks. He is quickly defeated by Lain, but the encounter puts Alice in a state of extreme shock. Lain is once again driven to protect Alice, and uses her power to rewrite memory/reality and erase herself from having ever existed. Alice, Eiri and all the others now live in a world where Lain never was.
Finally, Lain ponders what her existence is without anyone to perceive her. She loses all sense of identity and self, until she is saved by another power in the form of her (not actual) father. (This is the very end of the show and is left ambiguous, but this is likely supposed to be God. God also inspired Eiri to insert his consciousness in the Wired and God is capable of perceiving Lain, and thus ensuring her identity and existence, even when no one else can.)
In the last scenes, Lain says good-bye to Alice and the viewers, having accepted her role at God's side.
Okay. So let's go back. What is Lain?
My understanding is that she is basically a collective representation of the humanity. Just as the human mind is a manifestation of billions of neurons, all connected and exchanging information, Lain is the manifestation of billions of humans being connected and exchanging information. With the invention of the Wired, she was awakened. The Wired is a metaphorical brain for her, a literal network between humans.
Eiri identified her existence on the Wired and gave her a true physical body. (No idea how he did this. This is not explained at all. Cloning seems unlikely, perhaps he simply willed her into existence by altering everyone's memories? Personally, I believe her real-world body is related to the KIDS experiment.)
Lain always existed, since she is the collective sum of humanity. This idea can be understood as similar to the collective unconscious. Eiri took this abstract entity and gave it a physical form so he could manipulate it. (This was probably prompted by God, not just his own initiative.)
Since she is made of the human mind, her ability to alter memories is completely explained. She can change the minds of others the same way you or I would move our fingers.