This is the full FNAF lore as I understand it, not including Help Wanted, Security Breach, Ruin or Help Wanted 2.
In the early 1980's, two men named William Afton and Henry Emily opened a restaurant called Fredbear's Family Diner. This restaurant featured two animatronics that were named Fredbear and Springbonnie, a yellow bear and yellow rabbit. These animatronics used a kind of technology called springlocks, which pulled back the inner wiring and metal of the animatronic endoskeleton to allow for a person to wear the suit and walk around in it. They could also be unwound for the animatronics to walk around on their own and interact with guests. William usually wore the Springbonnie suit and Henry usually wore the Fredbear suit. The springlocks were extremely dangerous, so they very rarely allowed other employees to wear the suits unless they were thoroughly trained on how to properly work the springlocks. The diner became very popular very quickly, so William had the idea to open his own personal business, called Afton Robotics. He created a whole new set of animatronics on his own for this place called the Funtime animatronics. One was Circus Baby, a little girl dressed as a clown that he modeled after his own daughter, Elizabeth Afton. She is accompanied by small baby animatronics called the Bidybabs. Another was Ballora the ballerina, who is theorized to be modeled after Clara Afton, William' wife. She is accompanied by little ballerinas called the Minireenas. The final 2 are Funtime Foxy and Funtime Freddy. Freddy is accompanied by a Bonnie hand puppet called Bon-Bon. These new animatronics were featured at a restaurant called Circus Baby's Pizza World, where they were on display and available to rent for private parties.
Now, from the start, William was an extremely disturbed individual. When he programmed his new creations, he gave them certain specifications. He programmed them to lure, capture, and kill children. The example that we are shown is Circus Baby. In Sister Location, she is revealed to have bee programmed to always count and be acutely aware of the number of children in the room with her at any given time. When there is only one child in the room, she makes ice cream and displays it in her chest cavity. Inevitably, the child will come closer to retrieve the sweet treat, and when they reach for it, Circus Baby has a claw that jumps out and yanks the child into her body, crushing and killing the child. This is exactly what happened to Elizabeth Afton. Elizabeth was a curious child, and as she knew her father had modeled Circus Baby after her, she longed to see the robot for herself. Her father forbade this, however, knowing the murderous nature of the animatronic. One day, she snuck off to the room Circus Baby was displayed in by herself, and she was killed in the way mentioned before. After Elizabeth's death, William was beside himself. He couldn't bear to even look at his creations anymore, and so he locked them away in an underground location of Afton Robotics, which is where the events of Sister Location later happen.
William swore after this that he would never again lose his own children to his creations. He had two other children as well, two sons named Michael and Evan Afton, Evan being the younger of the two. Michael was the oldest. William decided that the way he would ensure he would not lose them by making Evan so terrified of the animatronics that he would not even go near the restaurant. He would put on an animatronic-themed mask and run down the hall towards Evan at night, scaring him and employing other tactics involving animatronic-themed merchandise that Evan owned, being the son of the owner. He also encouraged Michael to scare Evan frequently, adding to the boy's torment. When Evan's birthday came around, Michael had an idea for an amazing prank to scare Evan more than he ever had. He got his friends to all put on animatronic-themed masks with him and together they dragged Evan to Fredbear's Family Diner, Evan kicking and screaming the whole way. They brought him inside and forced him up to the stage where Fredbear ad Springbonnie stood. Michael forced Evan to put his head inside of Fredbear's mouth, Evan sobbing in terror. What Michael didn't know, is that springlocks are extremely dangerous and can be set off by on of two things. Either they come unwound from neglect, or when they come in contact with moisture. As mentioned, Evan was sobbing when Michael and his friends put his head into Fredbear's mouth. Evan's tears fell onto the springlocks and set them off, causing Fredbear's mouth to snap shut on his head. Now, Evan didn't die immediately. He was rushed to the hospital where he went into a coma and experienced the nightmares that we see as the gameplay of FNAF 4. The animatronic known as Nightmare in the game is, in fact, Fredbear, the last thing Evan saw before he was bitten. This incident is known as the Bite of '83, not to be mistaken for the Bite of '87.
After this, William realized he could not entrust the killing of children to his creations, as they could not differentiate between his own children and others. He had to take it into his own hands. Henry saw William's downward spiral into insanity, and decided that it would be best for William to take a step back from the business. William fought back, of course, insisting that he was fine and could run the business like before, but Henry knew better and forced him to leave, taking over Fredbear's himself. He knew William was likely to take revenge, so he took measures to protect his own family. Henry himself had a daughter, Charlotte Emily. He built an animatronic that he called the Security Puppet, also known as the Marionette. Its sole purpose was to watch over Charlotte and ensure that she was safe. It sat in a box by the door, making sure she never left the restaurant as she was a 3-year old child who would wander. However, some kids who frequented the diner noticed this and locked her outside one day, also confining the Puppet to its box. William drove by the restaurant, saw her outside, and decided to take his revenge on Henry. He took her into the alley behind the restaurant and murdered her. He left her body outside in the rain. The Puppet, freed from its box, went outside to look for Charlotte and found her lying in the alley. It broke down in the rain and ended up lying next to Charlotte's dead body. Somehow, her soul escaped into the Puppet and she possessed its body. Henry went outside to look for them, found them, and brought them back inside, devastated over the loss of his daughter.
Some time later, William came back to the diner during the day while it was open and guests were there. He went to the back, put on his old Springbonnie suit, and took five children from the restaurant to the back room. Once there, he brutally murdered all five children and stuffed their bodies into the extra animatronic suits that were back there. The children's names were Jeremy, Gabriel, Fritz, Suzie, and Cassidy. Jeremy went into a suit that became known as Freddy Fazbear, Gabriel went into Bonnie the bunny, Fritz went into Foxy the pirate fox, Suzie went into Chica the chicken, and there were no more extra suits so Cassidy was put into the old Fredbear suit, who would become known as Golden Freddy. The Puppet, now possessed by the soul of Charlotte Emily, helped the other children to possess their suits as she did hers. This means that there were now two souls within Golden Freddy, Evan and Cassidy. This is the first Missing Children's Incident. There is later another Incident where more children were killed, and it is theorized that they possess the Toy animatronics we see in FNAF 2, like Toy Freddy, Toy Bonnie, and Toy Chica. There is also another animatronic that was meant to be the Toy version of Foxy. However, it kept getting torn up by children playing with it, so eventually they left it as it was and marketed it as a "Take Apart and Put Back Together" animatronic. Because of it's disheveled and torn up state, the employees gave it the nickname of "The Mangle". There was an incident at the restaurant where an employee named Jeremy Fitzgerald was bitten by Mangle to the point where it severed his frontal lobe. This is the infamous Bite of '87. William was arrested for the Missing Children Incidents, but no charges were brought against him as no evidence was ever found. After being released, William went back to the restaurant at night to dispose of the corpses. He dismantled the robots, took the bodies, and put them back together. When he did this, he released the souls from the suits and they took on a physical form to attack him. When he saw this, he sought for a way to protect himself and found one old, reliable way. He took the only suit left, his old Springbonnie suit, and donned it once more, hoping to scare the children into staying away from him. However, he was sweating from fear and the old building had leaky pipes that dripped onto his suit, cursing him to a similar fate as that of his son Evan. The springlocks went off with him still inside the suit, trapping him in it forever. He laid there in that back room and bled out in the suit he used to cause pain and suffering. This is how he gained the name Springtrap. Eventually, with no one knowing he and the children's souls were there, the room was completely walled off and the building was abandoned and forgotten. For all intents and purposes, William Afton was dead and unable to hurt anyone. For now.
30 years later, the building reopened under a new name and with a new company. It was called Fazbear Frights, a horror attraction based on the legends of the missing children and the events surrounding the incidents. They opened the old safe room and found William, still inside his suit. Not knowing there was a corpse inside of it, they put it up on display in the attraction and William began roaming the place at night, as he had possessed his suit like the children had theirs. Now, Michael Afton had been searching for his father for the past 30 years because he had essentially disappeared after the Incidents, leaving Michael all alone as his mother had disappeared as well. It is debated what happened to Clara. Some say that after two of her children had died, she committed suicide. Others say she simply left. Another theory is that as William was spiraling, he murdered his wife and put her body into Ballora with the other Funtime animatronics underground. No matter the case, Michael was alone. He kept close to the Fazbear name by getting jobs as a security guard at the multiple different locations that opened, hoping his father would turn up so he could get an answer as to what truly happened to his sister and mother. Eventually, Michael went to the underground location of Afton Robotics to continue his search. The system recognized him as a technician, so he played along. While there, he found Circus Baby and Ballora and realized that his sister and mother were within them.
Circus Baby eventually guides Michael to the Scooping Room, where he learns that all of the Funtime animatronics have combined themselves into an amalgamation of parts and call themselves Ennard in the hopes of entering Michael's body in an attempt to escape the underground. They hope to do this by "scooping" him, using a giant metal arm called the scooper. It would crack his body open, removing his insides and leaving his skin behind for them to enter. They succeed in this endeavor and leave Afton Robotics behind. However, because they are inhabiting a corpse, it begins to rot after some time. Eventually they are forced to leave Michael's body as it has deteriorated too much to use. Somehow, Michael comes back to life and comes to be known as the Purple Guy (the second one, after his father William). Ennard enters the sewers and stays there for a long time. After a while, Circus Baby becomes too controlling for the other animatronics and they kick her out of Ennard. They both crawl around the sewers and rebuild themselves out of scraps they find. Circus baby becomes known as Scrap Baby and Ennard becomes Molten Freddy.
Now, Michael heard about Fazbear Frights and decided to take one last chance at finding his father. He gets a job as a security guard once again and finds his father. When he does, he is so overwhelmed with anger for what he did to his family that he tries to kill him by setting the place ablaze, but he fails and Springtrap now becomes Burntrap.
Later, Henry opened a new restaurant in hopes of luring all of the animatronics in to destroy them. He creates another animatronic that he calls L.E.F.T.E in order to find the Puppet and bring it in, as he knows his daughter is within it. L.E.F.T.E is an acronym that stands for Lure, Encapsulate, Fuse, Transport, and Extract. Henry, with the help of Michael, manages to lure every single animatronic to this new restaurant and they trap them within a labyrinth of Henry's creation, using the sounds of children, familiar sounds, and smells to keep them running around trapped, with no way out. Henry set it all up by himself. He put out an ad for a job for someone to help him bring all the animatronics in, and somehow it made its way to Michael. He is given instructions to run the restaurant and salvage the animatronics that he finds in the back alley. Henry gets everyone inside, gives a speech that is shown in Pizzeria Simulator and sets the entire place ablaze, killing himself, Michael, and releasing every soul trapped by William Afton. Henry planned a way out for whoever answered his job listing, but once he realized it was Michael, he knew he would not want to leave. Michael was already dead. His sole purpose was to exact his revenge upon his father for what he had done to his sister and (possibly) to his mother. Once that purpose was fulfilled, he could rest. He allowed himself to die in the fire since he no longer had a reason to continue living. Henry did the same. As shown in the final scenes of Pizzeria Simulator, Henry died with the Puppet, his daughter, in his arms. All the souls were released and they all went to rest. Except for two.
Two souls held on after the fire and did not move on. This was Cassidy, one of the children that possessed Golden Freddy. She is also known in Ultimate Custom Night as The One You Should Not Have Killed. She held on to William and refused to let his soul rest. She tortures him, putting him through an endless loop of death, over and over and over again at the hands of his own creations. She forces him to die again and again to the children he killed. Multiple animatronics in UCN have specific voicelines where you can hear a young girl's voice, presumably Cassidy, under the voice of the animatronic, proving that she is the one behind all of it. Eventually, she is confronted by Old Man Consequences, and he tells her to let William go, and to seek her own peace. This is where it ends. Or so we thought.
After the events of Pizzeria Simulator, Fazbear Entertainment didn’t know what to do with the loss of their two founders. A member of the company decided to go rogue and make a profit by creating a video game series based on the true events, rumors, and myths surrounding Fazbear throughout these fifty or so years. The company caught wind of his plan and approached him with an offer to bring him back into the business. They brainstormed ways to cover up the horrors, the abandoned buildings, the disappearances, etc. Fazbear Entertainment took the opportunity that these games presented and began to work on their own game with this developer, but under the official company name. This new game would make light of the myths and previous locations, a virtual reality game to make the players feel like they’re in the action themselves. It would be called Five Nights at Freddy’s: Help Wanted. The company also made plans for a new location since that’s what Fazbear had always been about. They decided to put it right on top of the location where Pizzeria Simulator happened, both to cover up those events and to save money on land. To raise money for this new venture, they reran all of the old merchandise they had sold, including plushies, toys, clothing, etc. While working on the game, they hired a 23-year-old woman named Vanessa. She had an extremely troubled past but was hired by Fazbear Entertainment to be the backup beta tester. While working, she befriended a coworker named Jeremy, who was the main beta tester for the game.
One day, someone high up in Fazbear Entertainment found some unused code from the old animatronics and directed the development team to scan the code into their system to help speed up the creation process. They didn’t think anything bad could possibly come of this, so they went ahead and implemented the real code into the game. What they didn’t realize was that the code they used came from Springtrap, and a tiny piece of William Afton’s soul was still attached to it. When they put the code into the game, William’s soul was implemented in as well and he managed to rebuild himself within the game as a glitchy version of Springbonnie, known as Glitchtrap. While play-testing the game, Glitchtrap begins to appear to Jeremy, calling out to him. Jeremy had no idea who or what it was, so he just called it “the anomaly.” He spoke out to the development team about this anomaly, but they brushed it off as a bug or glitch that the needed to fix. When Jeremy began to say that it was speaking to him, calling out, no one believed him. Fazbear Entertainment knew that something was wrong, that he was seeing something, but they didn’t care. Their only priority was getting the game out as soon as possible. They started working towards firing Jeremy, creating a paper trail of write-ups and infractions to make it look like he was a bad employee. However, he kept going, claiming he was having nightmares, hallucinations, hearing voices, all to do with this anomaly but no one cared. No one believed him. Finally, he decided to take matters into his own hands.
One morning, Vanessa went into work early and saw Jeremy standing in the supply room alone. She saw what she thought was a Halloween mask sprayed with ink. Jeremy’s shirt was also covered in ink, but she couldn’t see his face because of the VR headset he was wearing. What she didn’t realize at first was that it wasn’t ink, and it wasn’t a Halloween mask. Jeremy had cut his own face off using a piece of office equipment called a guillotine paper slicer. He had committed suicide to prevent the anomaly from taking over his mind and escaping the game. Soon enough, another employee saw Jeremy and reported it to the higher-ups. Vanessa decided to go talk to them about what she had seen, but before she entered the office, she heard voices. She overheard her manager speaking on the phone with someone about how Fazbear Entertainment was worried about a potential lawsuit, considering a suicide within the company and on the job would not be good for business. She also overheard that the “rogue” developer who had created the original games was actually hired by Fazbear Entertainment TO create those games. It was all an elaborate coverup, with the VR game finishing the job. When Vanessa finally walked in, she was told that she would be taking over Jeremy’s job as the main beta tester, and, afraid of what the company could do to her, she agreed. She began play-testing the game where Jeremy left off, and she began seeing the anomaly as well. She realized that Jeremy was right all along and decided to make logs of her experiences with the anomaly. Unfortunately for her, Glitchtrap began to attach himself to the logs themselves, within the game files. Now she could not delete them, as where the tapes were hidden was a safe, unremovable area in the files. Because Glitchtrap attached himself to them, he was essentially given a safe place to hide within the game, without detection or threat of being removed. Vanessa knew what she had to do. She broke the logs into pieces, warning anyone who might find them to never reassemble them, but it was already too late for her. Glitchtrap raids Vanessa’s mind. Now he does not take over her body, but he is in her head, pushing her and telling her to do certain things. William Afton is finally free of the game, and over time, he begins to have more and more of an influence on Vanessa, able to tell her what to do and where to go. In the real world, she ends up making a full rabbit suit by herself, modeling it after Springbonnie, thinking William would like it. She named it Vanny, similar to Bonnie. She becomes more and more of a reluctant follower of Glitchtrap and begins to make plans to bring him back into his own body. That was his plan all along, to fully come back.
Now, Fazbear Entertainment was very happy with the revenue they gained from selling merchandise and their new VR game, so they finally opened Freddy Fazbear’s Mega Pizzaplex, the aforementioned location above the burned-down one. Over time, the majority of work within the Pizzaplex ends up being done by new robots called S.T.A.F.F. bots. Their new animatronic band included Freddy Fazbear, Glamrock Chica, Montgomery “Monty” Gator, and Roxanne Wolf. Originally, they had Glamrock Bonnie, but he didn’t last long. One night, he was seen leaving his green room, heading to Monty Golf only for some reason to be destroyed by Montgomery Gator. It is theorized that Bonnie was the aggressor, due to him seeking Monty out himself. After this, Glamrock Bonnie was decommissioned and replaced by Monty as the bass player of the band. Vanessa shows interest in being a security guard for this new location and, despite her lack of experience, is recommended by someone high up in the company. This gets her hired as the head security guard for Freddy Fazbear’s Mega Pizzaplex. Within this new location, she dives deeper into her task to bring William back, using the futuristic technology of the Pizzaplex. Throughout their opening week, Vanessa murders multiple children attempting to fulfill her task, causing more missing children’s cases. She is also seen multiple times on cameras wearing the Vanny mask, acting suspiciously, searching strange things on the internet, etc.
Now for the events of Security Breach. During a performance, Freddy feels a dangerous presence in the audience that causes him to glitch out. He falls over, and we see Chica rush to him to attempt to help but he passes out. Freddy gets rebooted in his room and discovers that a child has hidden inside his chest cavity. A young boy named Gregory had snuck into the location and then into Freddy after he fell during the performance. He’s about to be locked into the Pizzaplex if he doesn’t get out before closing, so he follows Freddy’s instructions until he makes it to the front lobby. Unfortunately, just as he’s running to the doors, they shut right in front of him. Gregory is now trapped inside the Pizzaplex. Throughout the night, he explores the Pizzaplex with Freddy protecting him, learning more and more secrets about what really goes on there. He meets a new animatronic in the Daycare, one that has two personas: Sun and Moon. When the lights are on, Sun is your friendly babysitter who will play with you and clean up after you while your parents are doing their own thing. However, when the lights go out, Sun turns into Moon, a dangerous thing that wants you to go to sleep, at any cost. He traumatizes multiple children into refusing to sleep with the lights off. Gregory escapes the Daycare and continues exploring, but throughout all of this he has to fight off all of the animatronics on all levels of the mall (even underground). He learns that each animatronic, except Freddy, has recently been given a new upgrade. Monty received new claws when Bonnie was decommissioned so he could play the bass. Roxy was given new eyes so she could see through walls to be able to race better in Roxy Raceway. Chica was given a new voicebox, as her old one was distracting and debilitating to the other animatronics. Gregory destroys each animatronic and takes their upgrades, using them on Freddy. During all of this, Vanessa/Vanny is hunting for Gregory. At 6am, the doors open, and Freddy gives Gregory a choice. He can either leave, go home, and forget all of this, or he can stay and explore further to figure out the rest of what’s going on within the Pizzaplex.
Gregory chooses to stay. They find an elevator leading underground, all the way down to Freddy Fazbear’s Pizza Place, the old location the mall was built on top of. As they descend, Freddy begins to act strange, as if someone is possessing him. By going even lower into the Pizza Place, they find the same room Henry Emily sat in while saying his final words all those years ago. However, by using the futuristic technology of the charging stations located around the Pizzaplex, Vanny was able to almost reconstruct Scraptrap’s body and transfer William’s data from Glitchtrap into it. Finally, William Afton had truly come back, as he said he always would. Now, the company had just thrown all of the old, haunted animatronics down into this abyss of a location, knowing it would be covered up by the mall. Over time, they came together in an enormous amalgamation of parts (not unlike Ennard), knowing what Vanny was doing. However, neither Vanny nor William realized they were down there. William attempts to take over Freddy through the monitors, as he tried to do earlier during the performance. Gregory stops him by releasing fire into the room, distracting him from taking control, and Gregory fights all of the animatronics off on his own. The amalgamation witnesses what is going on, and after seeing William free, it grabs him. Gregory and Freddy, finally free, run away and escape the building. They sit down upon a familiar hill to relax, where we see five familiar graves. They are labeled Jeremy, Gabriel, Fritz, Suzie, and Cassidy. Gregory and Freddy finally get to have a happy ending. Until they bring it back once more with Ruin.