The story of Lightmatter is revealed throughout the game, and it can be confusing to understand as it is not revealed in chronological order. This guide aims to be a simple explanation of the plot, helping you to understand what actually happened and whether Virgil was actually evil. Obviously, this guide contains spoilers.
Before the Game
The majority of the story takes place before the game starts.
Virgil and his brother Arthur are exploring some caves on a mountain, and in one of these caves, Arthur finds a cool-looking crystal which he shows to Virgil. Arthur doesn't realise what it is, but Virgil somehow knows that it has great potential. Virgil leads the duo in creating his laboratory inside that very mountain, and Lightmatter is born.
Lightmatter soon starts to have some problems. Employees experience hair loss, which Virgil tries to fix by installing a mineral decontaminator. This, according to Virgil, "reduces cellular degradation by 34%", meaning that the hair loss subsides.
Arthur starts doing some experiments of his own by increasing the energy output of the CORE. This is because he trusts the laws of physics - the law of conservation of energy, specifically, which states that "energy cannot be created or destroyed, only transferred from one form to another". Virgil claims that the CORE is 107% efficient, meaning that 7% more energy is coming out than is going in. This is impossible, but Virgil, being a mentally insane scientist, believes that he truly has broken the laws of physics.
Virgil suspects that Arthur is betraying him by trying to overload the CORE, but in reality, Arthur is simply trying to find out where the additional energy is coming from. Shadows start to kill people, and it is revealed through one of Ellen's tapes that "the CORE is not a perpetual motion machine", and instead, all of the extra energy it appears to create actually comes from the organisms that the shadows consume. Arthur starts accusing Virgil of being reckless and a liar, and, knowing continuing with the project would cover the whole Earth in shadows, he starts to sabotage Virgil's efforts by attempting to destroy the CORE and deliberately poisoning employees in the hope that Lightmatter Technologies will be shut down.
Once Virgil finds out about Arthur's experiments and accusations, he and his "security manager" James murder Arthur on the grounds of betrayal. Ellen, an employee, starts recording tapes in which she talks about her discoveries. She starts by describing how she saw Arthur pouring liquids into her hair, causing hair loss. We as the player know later that this is because he wanted to get the facility shut down. She starts to talk about how she found Arthur's plans and figured out what he was trying to do, and how she was unable to destroy the CORE. We find out that she left the tapes in order for someone after her - the player - to complete her and Arthur's goal of saving humanity.
Both of their efforts failed, and Virgil welcomes "investors, journalists and all those who have doubted him" to the launch event. Suddenly, an employee (possibly Ellen?) turns up the CORE output and deadly shadows emerge around the facility. Guests are evacuated by James who takes them to the surface, where it is discovered that shadows have consumed the whole world. However, we do not find this out except in the alternative ending (which also grants the Baptized achievement).
During the Game
The plot moves on a lot during the game, while also finding out how things came to be.
The game starts just after all of the guests have been evacuated from the launch event. The player, whom we never really know what they are, has for whatever reason ignored the evacuation procedures. We meet Virgil as a silhouette before getting in the lift to be evacuated. However, the lift fails and the player drops all the way to the bottom of the mountain.
At first, Virgil suspects that the player is a health and safety inspector, but we never really know who they are. He guides them through a series of puzzles to a second elevator, but the bridge to it breaks just as you try to get there. Frustrated, Virgil asks James to find him another route, and more puzzles ensue.
Upon arriving at the second elevator, this one also breaks and the player is forced to retrace their steps until they are instructed to enter the Research and Development department. Virgil awards the player the title of his assistant, and, making their way through more puzzles, the player aims to end up at the CORE to shut it down and fix the shadows.
On the way to the CORE, we visit a room with an unknown button in it. Virgil instructs the player not to press the button, but in order to advance the game, we have to do it anyway. Betrayed for a second time, Virgil no longer refers to the player as his assistant but, as he still needs you to get rid of the shadows, he does not punish you.
Upon finally reaching the CORE, the player shuts it down, but to Virgil's amazement, "it's completely self-sustaining!". Virgil, who now believes that he knows how to fix the shadows, tells the player that there are no more exits, and to stay in that control room until he fixes the shadows. Ellen appears on a recording, who tells you to reactivate the CORE and follow her path to destroy it for good. If you wait 21 minutes without doing so, you unlock the alternative ending and meet Virgil in person.
Following Ellen's instructions, you make it to a lever to overload the CORE without Virgil's knowledge - she programmed the cameras to turn off when the CORE was reactivated. However, when you pull this lever, Virgil knows about your plan and gets very angry. He tries to kill you, but eventually, the player makes it to the lever to destroy the CORE forever.
Virgil begins to beg, but the player pulls the lever and the game ends. Virgil explains that the whole point of his experiment was to provide energy and food to everyone in the world, and tells you that, because you never gave him a chance to succeed, "their deaths are on you".