Though William Shakespeare could not be considered a historian by modern standards, he incorporates a great deal of history into his work. The way in which does so, however, tends to be more utilitarian than academic.
Shakespeare was a highly intelligent playwright. He was very well-aware of the political realities of his time, and as such, he brings that awareness to not only his choice of subject matter but also his decisions in portraying that subject matter. Much of Shakespeare's corpus of history plays can be divided into his ancient/medieval plays and his "contemporary" history plays.
In his ancient/medieval plays, specifically those with a setting of at least 150 years prior to Shakespeare's own time (i.e. those prior to the Wars of the Roses), he takes more liberties with matters of historical record, and he is more willing to do so. This is primarily because the events he depicts in plays like Henry V, Richard II, and King John had less apparent relevance to his own time. His depiction of Henry V in the play of the same name, as well as the events leading up to Agincourt tend toward the heroic, while the realities are far less glamorous. According to the historical record, Henry V the ruler does not correspond very closely to Henry V the character. Likewise, the battle of Agincourt in the play pays little attention to the stark realities of battle in the late Middle Ages. In short, many of his ancient/medieval history plays, while selective in their portrayal of historical content, tend to incorporate content that entertains. There are always exceptions to this rule, of course.
In Shakespeare's "contemporary" history plays, the content and the characters have immediate relevance to Shakespeare's own time. The most telling example of his "contemporary" history plays is Richard III. Though Richard III ruled approximately 75 years before Elizabeth I ascended the English throne in 1558, the historical events leading up to Richard III being killed in battle at Bosworth field in 1485, reflect political realities of Elizabeth's rule. Henry VII, Elizabeth I's grandfather, ascended the English throne after Richard III died in battle. Historically, the portrayal of Richard III and Henry VII (Earl of Richmond) varies a great deal from how they are portrayed in the play. Henry VII is portrayed as the savior of the English people, while Richard III is an evil usurper. Shakespeare, certainly aware of the political realities of his own time, understood that portraying Richard III as anything other than someone who is despiccable would not be possible. Doing so allows for Henry VII's gaining the throne and establishment of the Tudor line as legitimate, and by extension, Elizabeth I's rule is legitimate. As a general rule, in his "contemporary" history plays, Shakespeare is more concerned with political realities than the historical record.