The last part of chapter 8 of קהלת and the first part of chapter 9 discuss the fact that good things happen to bad people and bad things to good people. It notes that this is a shame, since it leads people to sin when they don't see sins punished. However, 9:1 is a brief intermission:
כִּי אֶת כָּל זֶה נָתַתִּי אֶל לִבִּי וְלָבוּר אֶת כָּל זֶה אֲשֶׁר הַצַּדִּיקִים וְהַחֲכָמִים וַעֲבָדֵיהֶם בְּיַד הָאֱלֹהִים גַּם אַהֲבָה גַם שִׂנְאָה אֵין יוֹדֵעַ הָאָדָם הַכֹּל לִפְנֵיהֶם
This says that what people do is in God's hands. (I'm using the מצודות for my understanding of קהלת, and my understanding of the verses follows their explanation.)
What does this have to do with the surrounding verses? (Indeed, if anything, it seems to contradict them: if our actions are not our own choice, then our sins would not be reduced by seeing others' sins punished.)