Jonathan Coulton, the man behind the iconic Still Alive from the original Portal, says that the song was initially set to be part of the middle of the game, a section where GlaDOS, the Artificial Intelligence at the center of the narrative, was trying to lure the main character into a false sense of security.
Coulton tells Rock, Paper, Shotgun
that, “Halfway through Portal, when you foil her plan to kill you, and you’re sneaking around backstage… she spends the rest of the game trying various ways to convince you to come back. And she tries everything and none of it works, and you really start to pity her.”
Apparently Eric Wolpaw, who handled the story for Portal, wanted to have a musical number in the middle of the game in order to create more emotion.
The launch version of the Valve game saw Still Alive linked to the final of the game and the end credits.