Does that mean all individuals who were born illegitimately would not be part of YHWH'S people? Or am I missing something? How long is a generation according to the Bible? Is it 40 years?
Deuteronomy 23:2 A mamzer may not enter the assembly of Adonai, nor may his descendants down to the tenth generation enter the assembly of Adonai.
First off, let’s clarify that the meaning of "mamzer" is uncertain. The word is used only one time in the Tanakh, and two times in the New Testament. The Tanakh, in fact, renders the word as "misbegotten", a clear indication that the meaning of the word, even in Judaism, is not at all understood. It only evolved into the common understanding of "a child of a Jewish father and a heathen mother", or "one of illegitimate birth", or as the KJV crudely puts it "a bastard".
There is a great body of evidence, however, to conclude that the term only meant that the mamzer simply could not fully participate in in religious rites at the Temple. In other words, the child is perfectly welcome to receive the rights, but could not participate (call it "hold office" if you wish) in the administering any religious rights on others.
Similarly problematic is the previous verse! "A man with crushed or damaged private parts may not enter the assembly of Adonai." We can see that it can be understood in the same manner.
There are many verses in the Bible which are very hard to comprehend today because we don't have the ancient language and cultural background to rely on for an accurate interpretation while we only read and try to understand using modern language.
As for your question about "generation" - when we read “generation” in the Bible, we have to consider the context. Usually, a generation in the Bible is roughly thirty years long or the people living during that time, the same as what we understand a generation to be in everyday talk.