Welcome. I apologize for being late to the party. I’ll try to work my way through the 70+ comments later.
The genealogies serve the same purpose they originally served when they were written/edited. TL/DR: They are a polemic against the Sumerian King List.
https://isac.uchicago.edu/sites/default/files/uploads/shared/docs/ois4.pdf#page=47
I’ll try to summarize the history of the Sumerian King List to save you the trouble of reading the whole article.
The first Mesopotamian king to be accorded divine status was Naram-sin. As the author memorably says,

The land was reunited in the third dynasty of Ur (Ur III, 2012-2004 BC) by Ur-Namma. In his 18-yr reign, he started (and possibly completed) ziggurats in the main cities of Ur, Uruk, Eridu and Nippur, but he died leading his troops in battle. This was a cosmic disaster.
His young son, Shulgi, took the throne under dangerous circumstances and ruled for nearly 50 years (2094-47). First, he had to fend off several attempts at foreign invasion, but then he had to undo the damage to the reputation he inherited from his father. The first 20 years of Shulgi’s reign were dedicated to that task. By the 21st year of his reign, all inscriptions attach the cuneiform sign for “god” before Shulgi’s name. How did that happen?
The next part is particularly relevant. Shulgi’s scribes “wiped the slate clean” and retrained the next generation of scribes in royal propaganda.
Finally, whew!, here’s the payoff:
So Shulgi had the Sumerian King List composed to legitimize his claim to divinity via descent from Gilgamesh. After his dynasty fell, the next picked up the SKL and added their own names to legitimize their rule as “descended from heaven.” It was political propaganda from start to finish. The scribes of a later dynasty added the names of rulers who came “before the flood,” and the lengths of their rules are between 43,200 and 28,800 years each for a total of 241,200 years.
The latter is what the genealogies in early Genesis write against. (I’m tempted to say “mock,” but that’s not exactly right, even though Isaiah mocks pagan beliefs in his writing.) The lifetimes of people before the flood in Genesis are long enough to give us pause, but they’re roughly 1000x shorter than the kings who lived before the flood in the SKL.
Now here’s the kicker. Babylonian kings who adopted the SKL to legitimize their claim to the throne continued to use the cuneiform for “god” before their names, but none after Shulgi had temples and cults dedicated to their worship. Instead, they became the gods’ representative on Earth, and kings were credited with every cultural advance. Genesis says, “Nope.”
The king isn’t the image of God – all of humanity is. And in the genealogies, the king isn’t responsible for building cities, inventing tents and livestock, musical instruments, or metallurgy. Ordinary people do all those things.
That’s the lesson we learn from knowing a bit of history.