In Thomas Kyd's "The Spanish Tragedy," (written in 1587) there is a character called the Duke of Castile. However, at the time the lands of Castile were part of the Dominion of King Philip II.
You can't be the Duke of an entire Kingdom, can you? That's having a Duke of England as well as a King of England. Philip II wouldn't have needed a Duke to act as a Viceroy, because he lived in Madrid, which was in Castile.
Why did Thomas Kyd name the character Duke of Castile? Was he just uneducated, or would there have been an historical Duke of Castile who the character would correspond to irl?
Your feeling is correct- Since the Crown of Castile and Aragon was a kingdom, there could be no such thing as a 'Duke of Castile'. Although the precedent exists in European history of independent duchies such as Florence, there exists no territory under the Crown of Castile that would have resulted in a Duke with that title.
Contemporary works by Shakespeare, and translations of the works of non-English plays, refer to characters of dukes by their actual titles (e.g. the Duke of York in Shakespeare's Richard II), and thus this instance of using such a title would not fit the trend of the greater body of works of the time.
The exact wording of the name is the only counterpoint I would make. In the play, there are a multitude of noblemen, some named and others not so. Although it was fast becoming archaic by the late 1500s, a way to refer to an individual would be to refer to the city or land where they heralded from, such as Phillip II Von Habsburg's family having originated with Habsburg Castle. Thus, given the linguistic manners of the time, Kyd could merely be referring to a duke 'from' Castile rather than a duke 'of' Castile.