I have been thinking about this for a while now.
The dukedom of York in the Peerage of England and the Dukedom of Albany in the Peerage of Scotland are traditionally reserved for the second so of monarch.
The randomness of history worked well for the Dukedom of York since its sixth creation.
If HRH Albert Victor, Duke of Clarence and Avondale had lived to become PoW, and then King, the title of Duke of York would have been transmitted to HRH Prince Edward of York (Future King Edward VIII, and future Duke of Windsor). Even in this case nature would have played it role, since the Duke of Windsor did not have any issue, so the title would have merged with the crown at his death.
The randomness of history (ie the death of the Duke of Clarence and Avondale) made the Duke of York the heir, and he became HM king George V and the title was merge back to the crown.
Fast forward a couple of years for the seventh creation of the title Duke of York for HRH Prince Albert, Duke of York (Future George VI). had HM King Edward VIII never abdicated, HRH Prince Albert, Duke of York would have remained Duke of York, and here again the randomness of history played a role, since he did not have any male issue,but rather, only Princess Elizabeth, and Princess Margaret Rose. So at his Death; the title of Duke of York would still have merged back to the crown. In reality he became King and the title merged back.
Eighth Creation HRH Prince Andrew, Duke of York, here again the randomness of history plays it role, since Prince Andrew does not have any male issue, but rather, Princess Beatrice, and Princess Eugenie. At this time, Andrew is 58 and is unlikely that he will have a male descendant, so the title of York will merge back to the crown at his death.
But it is entirely possible that in the future will have a string of title holders and male heirs (for instance, the actual Earl Spencer is the 8th, and his son will be the 9th). If and when this happens, the title of Duke of York, will cease to be a royal dukedom associated with second son of the monarch.
To avoid this situation, the titles of Duke of York and Duke of Albany should be made like the titles of Duke of Cornwall, and Princess Royal, this way they will be forever associated with the monarch, and always available to be granted when vacant to the second son of the monarch.