Major salt required ahead.
The story of Fnaf 4 occurs before the bite of 87. The person you're playing as is a child who is scared of the animatronics, something his brother uses to scare him. The brother and his friends wear the masks of the animatronics and decide to terrify the child further by making him kiss Freddbear (no not freddy, Golden Freddy). Unfortunately for the child his head in caught between the jaws of Fredbear, who in turn bites his lobe.
If we use fnaf 3 minigames as an example of what caused the birth of Springtrap, the minigames of fnaf 4 are the birth of another animatronic, the Golden Freddy as in the ending the child is shown crying next to his pulshies as they disappear one by one with Golden Fredbear being the last. This also may mean what is causing the child to see the nightmare animatronics.
Eventually the child dies, leaving his father a bitter man who seeks revenge against the children who killed him, even his own other son. Yes the child who we play in the game is the son of Purple guy. In his rage, purple guy murders the other children who bullied the child, even his own son, but the soul of the first slain child, the one crying outside of the diner when purple guy comes and kills him, haunts the puppet who decides to give those who tormented the younger brother a second chance thus he gives gifts, gives life.
Eventually as the story progresses the Freddy Fazbear Entertainment company closes and purple guy is caught and eventually leaves or escapes prison. Perhaps the reason why he returns to the closed down pizzeria is because he is suffering the same nightmares his young son faced and believes that by destroying the animatronics he will be rid of the ghosts of his sins. But the children return and block him in the room where the faulty animatronic suit hybrid is. In terror Purple Guy dons the suit and laughs as he sees the ghosts not closing in on him. Perhaps the ghosts recognize the suit as one of the animatronics that were on stage when the tragedy first occured. Eventually the spring suit malfunctions, killing purple guy and leaving his soul to haunt the suit whilst the ghosts of the children leave, whether damned to continue haunting the pizzeria as phantoms or free from their suffering due to the give cake minigames, we know not.
Several years later Fazbear Fright is about to open when they discover one animatronic in existence in the old pizzeria, Springtrap. As seen in the ending of Fnaf 3, the exhibition burns down with the remaining pieces sold in an auction. Whether Springtrap is alive or not, the games have not told.
In conclusion, the Bite of 87 occured because a brother and his friends decided to torment the younger brother which in turn caused the infamous bite. The animatronics at the time were scrapped in favor of the toy animatronics, who in turn began to malfunction as someone messed with their facial scanners. This led to the toy animatronics to be scrapped and the older models to be reinstated and rebuilt. This might explain why the child has the Springtrap pulshie and how Freddy, Chica, Bonnie and Foxy were in the same timeline as Golden Freddy and Golden Bonnie. Perhaps the Golden animatronics were to replace the previous four, but due to their malfuntioning nature were scrapped alongside the original four in favor for the toy animatronics.
Anyways that's how I see the story.