I'm looking for reasons (Pshat, but not only) in giving so much detail in Bereshit regarding the sons of Adam, Kain, and so on. Some of the characters born and die, and have no clear role, at least in Pshat.
In the beginning of his commentary to Genesis Chapter Four, Ralbag enumerates four reasons for the Torah's protracted genealogical/biographical discussions. The first one directly addresses your question:
הראשונה לישב לנו אמונת החדוש וכבר זכרה הרב המורה וזה כי מפני שספרה לנו התורה שהעולם מחודש ושהנברא ממנו ראשונה הוא איש אחד לבד יפול ספק חזק לאנשים על זה המאמר בראותם בישוב אומות רבות מתחלפות מלאו את הארץ ולשונותיהם חלוקים ויחשבו מפני זה שיהיה מה שהגידה התורה מזה כזב כי האנשים אשר הם מאיש אחד ראוי שידברו בלשון מולידם וימשך לזה שלא יהיה נמצא כי אם לשון אחד [לבד] אם הענין כמו שסופר בתורה ר"ל שיהיו כל האנשים בני איש אחד כל שכן שיהיה זה יותר רחוק להאמין שישלם זה בכמו זה הזמן המועט אשר היה בין בריאת עולם ובין מתן תורה וכאשר ספרה לנו התורה איך הסתעפו האומות המתחלפות מאדם הראשון ומה היתה הסבה אשר הביאה להחלק הלשונות הוסר זה הספק עם שבזה האופן מהתישבת זאת האמונה בלבנו ר"ל אמונת החדוש כי כשהוגדו לנו אלו התולדות איך היו ושמות הנולדים ומספר חייהם עד שנמשך הענין עד הדור שנתנה לו התורה התישבה בלבנו יותר זאת האמונה
The first one is to instill in us the belief in creation, and Maimonides has already mentioned this. And this is because since the Torah tells us that the world was created, and that originally only one man was created from it, a strong doubt would befall people about this statement when they see many different nations inhabiting and filling the world with different languages. They will think on account of this that that which the Torah tells about this is false, since people that are from one man should all speak the language of their birth. Thus, if the facts are as the Torah says – namely that all people are the descendants of one man – the result should be that there would be only one language. And it would certainly be even more far-fetched to believe that all this occurred in the very short time between the creation of the world and the giving of the Torah.
Now when the Torah tells us how all the different nations branched out from from Adam, and what the cause was for the differentiation of languages, this doubt is removed. It also settles this belief in our hearts, i.e. belief in creation. For when [the Torah] tells us these generations – what the names of those born were and the length of their lives – until it extends all the way to the generation that was given the Torah, this belief will become more settled in our hearts.
Here is the explanation of Rambam, mentioned by Ralbag above:
Guide for the Perplexed 3:50
Every narrative in the Law serves a certain purpose in connexion with religious teaching. It either helps to establish a principle of faith, or to regulate our actions, and to prevent wrong and injustice among men; and I will show this in each case.
It is one of the fundamental principles of the Law that the Universe has been created ex nihilo, and that of the human race, one individual being, Adam, was created. As the time which elapsed from Adam to Moses was not more than about two thousand five hundred years, people would have doubted the truth of that statement if no other information had been added, seeing that the human race was spread over all parts of the earth in different families and with different languages, very unlike the one to the other. In order to remove this doubt the Law gives the genealogy of the nations (Gen. v. and x.), and the manner how they branched off from a common root. It names those of them who were well known, and tells who their fathers were, how long and where they lived. It describes also the cause that led to the dispersion of men over all parts of the earth, and to the formation of their different languages, after they had lived for a long time in one place, and spoken one language (ibid. xi.), as would be natural for descendants of one person.
One approach is found in Pirkei Avot 5:2
עֲשָׂרָה דוֹרוֹת מֵאָדָם וְעַד נֹחַ, לְהוֹדִיעַ כַּמָּה אֶרֶךְ אַפַּיִם לְפָנָיו, שֶׁכָּל הַדּוֹרוֹת הָיוּ מַכְעִיסִין וּבָאִין עַד שֶׁהֵבִיא עֲלֵיהֶם אֶת מֵי הַמַּבּוּל. עֲשָׂרָה דוֹרוֹת מִנֹּחַ וְעַד אַבְרָהָם, לְהוֹדִיעַ כַּמָּה אֶרֶךְ אַפַּיִם לְפָנָיו, שֶׁכָּל הַדּוֹרוֹת הָיוּ מַכְעִיסִין וּבָאִין, עַד שֶׁבָּא אַבְרָהָם וְקִבֵּל עָלָיו שְׂכַר כֻּלָּם: [There were] ten generations from Adam to Noah, in order to make known what long-suffering is His; for all those generations kept on provoking Him, until He brought upon them the waters of the flood. [There were] ten generations from Noah to Abraham, in order to make known what long-suffering is His; for all those generations kept on provoking Him, until Abraham, came and received the reward of all of them.
The gist of this idea is that listing all the non-primary people in Bereshit is meant to complement the lessons that the Torah wants us to learn from Noach and Avraham.
A somewhat related explanation is given by Rashi in Bereshit 37:1
וישב יעקב וגו'. אַחַר שֶׁכָּתַב לְךָ יִשּׁוּבֵי עֵשָׂו וְתוֹלְדוֹתָיו בְּדֶרֶךְ קְצָרָה, שֶׁלֹּא הָיוּ סְפוּנִים וַחֲשׁוּבִים לְפָרֵשׁ הֵיאַךְ נִתְיַשְּׁבוּ וְסֵדֶר מִלְחֲמוֹתֵיהֶם אֵיךְ הוֹרִישׁוּ אֶת הַחֹרִי, פֵּרֵשׁ לָךְ יִשּׁוּבֵי יַעֲקֹב וְתוֹלְדוֹתָיו בְּדֶרֶךְ אֲרֻכָּה כָּל גִּלְגּוּלֵי סִבָּתָם, לְפִי שֶׁהֵם חֲשׁוּבִים לִפְנֵי הַמָּקוֹם לְהַאֲרִיךְ בָּהֶם, וְכֵן אַתָּה מוֹצֵא בְּי' דוֹרוֹת שֶׁמֵּאָדָם וְעַד נֹחַ פְּלוֹנִי הוֹלִיד פְּלוֹנִי, וּכְשֶׁבָּא לְנֹחַ הֶאֱרִיךְ בּוֹ, וְכֵן בְּי' דוֹרוֹת שֶׁמִּנֹּחַ וְעַד אַבְרָהָם קִצֵּר בָּהֶם, וּמִשֶּׁהִגִּיעַ אֵצֶל אַבְרָהָם הֶאֱרִיךְ בּוֹ. מָשָׁל לְמַרְגָּלִית שֶׁנָּפְלָה בֵּין הַחוֹל, אָדָם מְמַשְׁמֵּשׁ בַּחוֹל וְכוֹבְרוֹ בִּכְבָרָה עַד שֶׁמּוֹצֵא אֶת הַמַּרְגָּלִית, וּמִשֶּׁמְּצָאָהּ הוּא מַשְׁלִיךְ אֶת הַצְּרוֹרוֹת מִיָּדוֹ וְנוֹטֵל הַמַּרְגָּלִית.
AND JACOB ABODE — After it (Scripture) has described to you the settlements of Esau and his descendants in a brief manner — since they were not distinguished and important enough that it should be related in detail how they settled down and that there should be given an account of their wars and how they drove out the Horites (see Deuteronomy 2:12) — it explains clearly and at length the settlements made by Jacob and his descendants and all the events which brought these about, because these are regarded by the Omnipresent as of sufficient importance to speak of them at length. Thus, too, you will find that in the case of the ten generations from Adam to Noah it states “So-and-so begat so-and-so”, but when it reaches Noah it deals with him at length. Similarly, of the ten generations from Noah to Abraham it gives but a brief account, but when it comes to Abraham it speaks of him more fully. It may be compared to the case of a jewel that falls into the sand: a man searches in the sand, sifts it in a sieve until he finds the jewel. When he has found it he throws away the pebbles and keeps the jewel (Midrash Tanchuma, Vayeshev 1).
While it may seem like the Torah is expending a lot of energy listing the generations from Adam to Avraham, it's really all of two (admittedly quite large) Parshios (with one of them largely devoted to Noach), which relative to the rest of the Sefer isn't that much (it's 20 generation for the first two Parshios, followed by 10 Parshios talking about the next 4 generations). It's still clear that the main focus of the Torah is on Avraham and his descendants without as much of a focus on the earlier generations.