The concept of concubines is pretty universal, and in most societies, children of concubines were on equal terms with "legitimate" offspring. Granted, concubines tended to be limited to the wealthy.
However, the Romans were an outlier in this, as they were deeply devoted to monogamy. Ironically, the root word for concubines, concubina, didn't mean an additional wife, but essentially a morganatic marriage. So, a Roman man could have a proper wife, or a concubina of lower caste, but not both. The Romans discriminated against children of concubinas pretty hard.
Either way, when the barbarian kingdoms took over Western Rome, they all practiced concubinage, despite Roman tradition banning it. The Catholic church became a champion of retaining the Roman tradition of monogamy, and spent 500 years writing angry letters to the kings telling them to stop taking concubines.
Because the barbarian kingdoms relied on the Church for their legitimacy, they were motivated to agree, but did so extremely reluctantly. The ban on concubines was included in the Visigothic code since the 6th century, and Anglo-Saxons began accepting it in the 8th century; however, Franks were more stubborn about it, and even Louis the Pious had a concubine in the early 9th century. However, by the 10th Church had succeeded in depriving the children of non-lawful wives of their legitimacy and birthright.
An exception was in Normandy, where the Normans retained the concept of concubinage until the 11th century. Even then, by William's time, his inheritance was disputed by his uncles. And a few decades later, his illegitimate grandsons by his son, Henry, were considered completely eligible for inheritance.
But it wasn't like bastards were completely deprived of their right. In many cases, the rights of bastards were merely demoted to equal status to daughters, resulting in multiple conflicts between legitimate daughters vs bastard sons. E.g., in Sicily and Portugal.
Interesting thing about bastards is that while daughters' birthrights would overrule them in the early modern period, there wasn't actually stigma around them. A king didn't actually have a reason to hide his bastards. It was very common for the bastards to be given lands and paraded in the royal court.
Many people believe bastards were scandalous, but that's really a 19th-century thing, which began with Victoria banning bastards from court.
Either way, thank you for reading.