Shakespeare based Macbeth on historical information from Holinshed Chronicles of England. James I was the king of Scotland when he came to the English throne in 1603. Macbeth was first performed in 1606. During this time, it was believed that James' ancestors could be traced back to Banquo. So, the play, known as Shakespeare's "Scottish play," is somewhat of an homage to James I and the lineage of English (and Scottish) royal history.
Shakespeare likely used more than one story from the Holinshed Chronicles. In one story, King Duff has killed members of Donwald's family for allegedly conspiring with witches. Donwald then kills the king (Duff). In Macbeth, Macbeth and Banquo deal with witches and they also (like Donwald) kill the king. The difference is that in the Chronicles, Banquo is Macbeth's accomplice; in Shakespeare's play, Banquo is innocent.
Shakespeare drew from a number of sources for many of his plays. Some scholars believe that George Buchanan's text, Rerum Scoticarum Historia, is also a possible source for Macbeth. Shakespeare certainly did pool from a number of sources but he also changed some of that information to suit his storytelling. In addition, Shakespeare drew from other texts and made allusions to other historical and/or literary figures when it was appropriate. For example, in Act 3, Scene 1, Macbeth makes a reference to the murder of Caesar. Macbeth fears Banquo (because of the witches' prophecy that his descendants would be kings). Therefore, Macbeth compares himself and Banquo to Mark Antony and Caesar:
There is none but he
Whose being I do fear; and under him
My genius is rebuked, as it is said
Mark Antony's was by Caesar. (III.i.58-61)
Macbeth feared Banquo just as Antony feared Caesar.