This is a large question, so I'll focus on Julius Caesar. Shakespeare probably used historical sources (though we can't be positive about this) as the material for his plot constructions. It's also possible he simply used the education he had received regarding the events surrounding Caesar's death, and dramatized from there. We can't know for sure.
As any dramatist worth his salt will do, Shakespeare is using these historical events to create a dramatic event. And so, he creates two characters Cassius and Brutus, who, in the play, couldn't be more different in motivation and style. The detail with which Shakespeare draws the hot-headed Cassius' disdain of Caesar's sense of self-importance ("he doth bestride the narrow world/Like a Colossus") as opposed to the rational, cautious Brutus ("Let us be sacrificers, but not butchers") serves the dramatic necessity of conflict, not necessarily history.
The same could be said for the characters of Antony, Caesar, Octavius -- all of these are famous historical figures, but their behaviour and relationships, as depicted by Shakespeare, serve the play's dramatic structure -- a tragedy, in which Brutus is the tragic hero. Brutus' strengths -- his honor, cautious nature and love of country -- turn out to also be his weaknesses. aspects of his tragic flaw. He cannot see others as they clearly are, only through the lens of his own sense of allegiance and honor.
So, though Shakespeare has followed the general outline of historical events, he has created characters whose behaviour and motivations suit his dramatic intents. His purpose was entertainment, not historical accuracy.
I've included some links that examine the question of history and Julius Casear in more detail.
Get Ahead with eNotes
Start your 48-hour free trial to access everything you need to rise to the top of the class. Enjoy expert answers and study guides ad-free and take your learning to the next level.
Already a member? Log in here.