The novel of Siddhartha is divided into two parts, each part divided into four and then eight parts. The reason for this is to parallel the Eastern beliefs of Hinduuism and Buddhism.
Part 1 is the Four Noble Truths, each section representing one of these 1) Existence is suffering 2)Suffering rises from desire 3) Suffering ends when desire ends 4)The way to end desire is to follow the Eight-Fold Path to Nirvana.
Part 2 is representative of Siddhartha's Eight-Fold Path to Nirvana: 1) Right belief 2) Right resolve 3)Right speech 4)Right conduct 5)Right occupation 6)Right effort 7)Right contemplation and 8) Right ecstasy.
Now, to answer your question: the theme of discontentment is explained in Siddhartha's attempt to follow these teachings. He is unable to stay anywhere for any real length of time until he reaches a Nirvana of sorts with the Ferryman well into Part 2.
He is discontented with the Brahmin way of life, and so he leaves (desire for knowledge). He stays with the Samanas until he realizes he can learn no more from them, so he leaves to seek out Gotama. Siddhartha is not discontented with Gotama, but he realizes that Gotama has reached Nirvana but his teaching don't teach others how to reach it. Siddhartha must keep looking. He comes to the realization that he must be his own teacher, not blindly follow others' teachings. This is where we begin Part 2, the Eight-Fold Path to Nirvana. This journey explains to us more of Siddhartha's discontentment. He falls into the material world of love, lust, greed, and power. It is almost as though he is trapped and cannot escape even though he loathes this life. Finally, he breaks free and literally becomes one with himself and the world with the help of the river. It is not until Siddhartha's son appears that he becomes discontent again...albeit for different reasons. Once he realizes that life is cyclical (what his son has done to him, he once did to his own father) and that the path to Nirvana must be found for each individual by that individual, he again is at peace by the river. Even Govinda realizes this as he speaks with Siddhartha and kisses his forehead, for Govinda is also discontented and searching for Nirvana.