This is one of Shakespeare's earlier tragedies though it probably falls more into the category of a history (particularly since it is the final play in the history cycle). A history it might be, though it can be argued that it is not an accurate history, but instead a piece of propaganda that was designed to cement the power of the current Tudor dynasty (not that Elizabeth I needed anything to cement her power).
The play is set in the closing years of the Wars of the Roses. This was a civil war in England between two noble houses, Lancaster and York, and rulership of the realm shifted between both of these houses during the period. Richard was not an illegitimate ruler since his brother Edward did name him as Lord Protector, but that was because he intended his eldest child would inherit the throne. However when his children disappear in the Tower of London, that obviously was not going to happen (though it is pretty clear in the play that they were murdered on Richard's orders).
It has been argued, and I tend to agree, that the purpose of this play was to demonise Richard of Gloucester, turning him into an usurper and a tyrant as opposed to simply another ambitious ruler. There is no evidence that he actually murdered Edward's children (other than this play of course, but the play was produced 100 years after the events in which it depicts), and contemporary sources suggest that he may not have been as tyrannical as Shakespeare made him out to be.
The play tracks the course of Richard ascension to the throne, and then his descent into tyranny, and finally his defeat at the Battle of Bodsworth field, which brought an end to the war and secured the Tudor dynasty on the throne. However, despite the propaganderous nature of this play, in those days legitimacy was still, even in a civilised country like England (to the extent that one could call England civilised), determined by the relative power of the ruler. He who had the strongest forces ended up being the one entitled to rule. This is clear when Richard was defeated as Henry ascended the throne and from his loins came the Tudor dynasty (which lasted about 100 years).
It is also interesting to note that unlike the English civil war, which was a war between the protestants and the Catholics, as well as a war between the parliamentarians and the monarchists, this was a classic medieval civil war where two royal houses strove for dominance. It is not surprising that this war broke out because it occurred immediately on the heels of the unsuccessful Hundred Years War where England attempted to conquer France and failed. It is not surprising that this happened as defeat in a war generally signals weakness in a ruler, and when a ruler is seen to be weak then his authority will be challenged. Another aspect of this period is England moving from the medieval world into the modern world as, after this period, England was stable, politically at least, until the outbreak of the civil war, though during that period we see the split from the Catholic Church (another sign of the country's movement into the modern world), and the development of a very strong literary culture.
For those who are interested, I have written a blog post on Richard III, specifically focusing on the 1995 film starring Ian McKellan.