Today I'm going to focus on the critical role of legitimacy in determining who can and can't inherit a title.
Legitimacy in this case cannot be conferred retroactively, and is based on one's parents' marital status at one's birth, not conception. If a duke marries his pregnant mistress as she's going into labor, the child (if a son!) can inherit as long as the vicar completes the ceremony before the birth. If they marry when the infant is a few hours old, that baby is out of luck. This is one of the most common fictional errors with respect to titles and inheritance--a peer legitimizing a bastard son or grandson. Couldn't happen. The law made no provision for it.
A case in point is Wellington's oldest brother Richard. As a young man, he took up with a French actress, with whom he had five children...and only afterward married her. The fact that he eventually married their mother did nothing whatsoever to confer legitimacy upon those children. It probably made them more socially acceptable--both of the daughters made reasonably good marriages, one to a baron, the other first to a baronet and second to the younger son of a duke. But there was no way the eldest son could inherit his father's titles. Once illegitimate, always illegitimate.
Richard Wellesley held two titles: that of Earl of Mornington, which he'd inherited from his father, and Marquess Wellesley, granted for his services as Governor-General of India at the end of the 18th century. Upon his death, the latter title became extinct, since he had no legitimate sons to pass it on to. But since the Mornington title came from his father, it did not die out but went to Richard's brother, William, second oldest of the family, and then to his son and grandson. At that point, in 1863, William's direct male line died out, and the earldom passed to the descendants of the third Wellesley brother, Wellington himself. And there it remains to this day--as mentioned a few weeks ago, the eldest son of the eldest son of the present Duke of Wellington uses Earl of Mornington as his courtesy title.