I have a different opinion on this; These tangents are not random at all. They've all contributed to the content of the story in their own way. In fact, I believe that these tangents are one of the things that has made this book a masterpiece. Exactly in the same fashion that short and brief descriptions has made The Old Man and the Sea a masterpiece.
Let's talk about the Bishop description for example; as we read, Valjean is the farthest thing from a good person. He is angry, hates society for being unfair, etc. Hugo bothers himself a lot to describe his personality in this manner. Afterwards, it is read that a meeting with a Bishop, an accidental one, wakes a man as lost as Valjean is and later in the story, he becomes a savior for the society and people around him!
Now let's assume for a second that the description about Bishop was not included or was briefed. Then wouldn't we have wondered what just happened? who was this guy that turned a sociopath into a saint? But it is only after reading these descriptions that we realize that only a man as saintly as the Bishop, could turn a man as lost as Valjean into a saint:
It is not possible to know how far the infulence of any amiable honest-hearted man flies out into the world; but it is very possible to know how it has touched one's self in going by...
Like Dickens said in Great Expectations.
This and all other tangents, in their own way, answer questions that may occur to the readers' minds or gives them a better understanding of individual parts of the story, like the in depth explanation about the sewage system. To conclude, I'd say that none of Hugo's tangents are random or just a way to wipe the empty spaces. Remove them from the book and in my opinion you'd kill what makes this book a masterpiece.