The Parisian Sewers first appear in the fifth Volume in Victor Hugo's novel, Les Misérables, where it is used as an escape from the barricades by Jean Valjean.
In the Novel
After the events of the final battle, Marius is severely wounded by the national guard. In an attempt to save him, Jean Valjean carried his body through the nearby sewer passages without being spotted by the soldiers. After presumably walking for several hours, Valjean is lost, before bumping into Thénardier. In the novel, Thénardier does not recognize Valjean, believing him to be a random criminal planning to dispose of a body. After giving Valjean the sewer key and brief direction in exchange for half the contents of Marius' pockets, pair part (in the 2012 movie, Thénardier steals Marius' ring and is attacked by Valjean). It is later revealed that Thénardier was hiding the sewers after fleeing from Javert, causing Valjean to be confronted with the inspector at the sewers' exit.
In the musical and 2012 Movie
In the musical and 2012 movie, the sewers serves the same storyline purposes as it served in the novel, except Thénardier recognize Jean Valjean (consequently, not offering him any rope), and is robbing bodies instead of running from Javert. No key was needed to leave the sewers in these interpretations. The sewers are visited in only two songs, "The Sewers", a purely instrumental song, and "Dog Eats Dog", a song where Thénardier sings while robbing the bodies of dead revolutionaries and soldiers.