The problem with the rights of children born out of wedlock has sure been a problem and caused a lot of problems throughout history!
In Denmark, the Law of Succession states very clearly that only children born within a legal marriage (*) can claim the throne.
Beforehand in the 15-1700's, acknowledged children born out of wedlock got the title of Gyldenløve = Goldenlion, which was not hereditary. They were the fortunate ones, they at least had a resonable position in life to start from.
The rest, well, at best the mother got some money as compensation. And sometimes the mother could confide to the child: "You are really the son/daughter of a king/prince".
Illegitimate children wasn't really a problem except for those with a position and in particular in connection with inheritance, for everybody else below that position in life, they were an extra set of hands. Children were after all born out of wedlock all the time. People were no better back then than they are now. The more strickt and Christian interpretation of moral only gained some popularity much later.
(*) Legal marriage back then meant a Lutheran wedding. It was not unheard that kings married to their "left hand", King Christian IV did.
He married his mistress and by marrying her to his left hand, she gained status as the kings official and beloved mistress. She was officially treated as his second wife, subserviant (officially and in theory) to the queen.
That was seen as a very practical solution to the problem of the king having a relationship based on love and at the same time being married out of duty. Now, the mistress didn't have to hide or visit the king in secrecy and should he die, her status was still secured. - I.e. quietly retiering to some manor somewhere.
And as official mistresses were mostly noble, she and her family, retained a status that was worthy of the status she was born into.
Just as importantly, any children were officially aknowledged with all that implied.
The church, unsurprisingly, was very much against the practise of "marrying to the left hand" and managed to stamp it out eventually.
(Very breifly and simplified).