Many of the characters saw significant changes throughout TBBT.
Howard for instance went from being a quite creepy woman-obsessed singleton to a happily settled family-orientated husband. Even Sheldon, who was notoriously not interested in the opposite sex, eventually found Amy, who he very much enjoyed a loving relationship with. However, out of all the transformations in the series, Stuart perhaps saw the most significant. And it was all due to one line that originally was never in the script at all.
How Stuart changed over the series
Stuart first appeared in Season 2 of the show and was introduced as the owner of a local comic book store. Apart from only interacting with the 'nerds' who visited his shop, Stuart appeared as a fairly normal guy.
We find out that he graduated from art school, which is why he opened the comic store. He also does not seem to share the same social anxiety as some of the others who visit his store. In fact, upon his very first appearance, Stuart goes on a successful date with Penny while not knowing Leonard has feelings for her. Although Sheldon eventually ruins the date, Stuart seems like a pretty average guy.
Why Stuart's personality changed
Over the run of the series, Stuart continued to guest star on multiple episodes of the show. And it wasn't until Season 3 that the character would deliver a line that changed his role in the series completely. In episode 7 "The Guitarist Amplification" Sheldon spends most of the time hiding from his friends, as he is annoyed by their bickering. He decides to hide away at Stuart's comic book store, where he thinks it is safe. Eventually, Leonard and Penny track him down, and it is at this moment that Stuart delivers his fateful line.
Kevin Sussman, who played Stuart on the show, was meant to briefly interact with Leonard and Penny as they entered the store.
However, in an unscripted moment, Sussman whispers "I love you" as Penny walks away. Not only was this a hilarious ad-lib, but it showed a new side of Stuart, who was not only still pining for Penny after their one and only date, but as a depressed and lonely character.
It may have kept Sussman on the show
Sussman's improvised line went down so well, not only did they end up keeping it in the show, but his depression became the entire focus of the character. According to Sussman, who discussed the moment at the 2021 Paris Manga & Sci-Fi Show, he believes this one line changed the course of Stuart forever.
Although Sussman was only meant to appear as a one-off guest star originally, the showrunners kept bringing in back for more appearances. Eventually, he became a regular of the series from season 8, and Stuart eventually appeared in 84 episodes of the entire show.