TV producer Alan Sachs wanted a Lovin' Spoonful-like theme song for a new ABC sitcom entitled Kotter. Sachs's agent, Dave Bendett, also represented Sebastian and arranged for a meeting between the two.
Initially, Sebastian had considerable difficulty with the lyrics since including the title character's name didn't lend itself to a sufficient number of obvious rhymes. Instead, Sebastian decided to focus the lyrics on the idea of the series' premise of Kotter returning to the very place he grew up and having dreamt of leaving to do something positive.
The producers liked the resulting song so much that they changed the name of the series to Welcome Back, Kotter. Co-produced by Steve Barri and Sebastian, the song eventually sold over one million copies.
The song originally had one verse, meant for the TV series. Because of the popularity of the show, Sebastian, in the single version, added a second verse to the song, as well as an instrumental section featuring a harmonica solo, before he resumed finishing up the verse, as well as the repeated chorus and coda to finish the song. The single version would eventually be used during the closing credits of Welcome Back, Kotter. Some final season episodes play the entire song, less the instrumental section, during the closing credits.