In addition to the excellent answers given above, I would like to point out that Shakespeare called his play Macbeth a tragedy. Evidently he wanted the audience to feel a certain amount of pity or sympathy for Macbeth. Shakespeare seems to have taken pains to make it appear as if his hero is not entirely to blame for what happens to him. He doesn't want to kill Duncan, but his wife overcomes his scruples with her verbal manipulation. Furthermore, the Weird Sisters make it seem that what he has to do in order to become king is already decreed by fate.
As far as the actual murder is concerned, it seems likely that Shakespeare decided to keep it offstage because it would create a much worse impression of his tragic hero if the audience saw him sneak into the bedchamber and murder the kindly old man in his sleep. It is true that Banquo's murder is shown onstage, but it is noteworthy that Macbeth does not take part in the actual killing. In fact, when Banquo's ghost shows up at the coronation banquet, the first thing Macbeth says to him is:
Thou canst not say I did it. Never shake
Thy gory locks at me. (III.4)
And when Macduff's wife and son are murdered in Act IV, Scene 2, the atrocity is committed by Macbeth's agents, while he is far away.
In spite of Shakespeare's attempt to preserve some shred of viewer sympathy for Macbeth, he still does not seem to qualify as a tragic hero. Rather than having a single tragic flaw, Macbeth has many. He is courageous, but he is treacherous, ruthless, gullible, uxorious, and incompetent as a ruler.
It is interesting that Duncan's death is not shown: other deaths in the play, for example, Banquo's are shown; Roman Polanski's film version graphically depicts Duncan's murder.
One reason would be to suggest the murder of a king is too terrible to be shown so the audience has to use their own imagination. Indeed, the audience never sees the King's dead body. Another reason is also to do with the audience. It is by no means certain that Macbeth will be able to carry out the killing: the floating dagger which he has just seen would have dissuaded most people! Therefore, ending the scene just as Macbeth enters Duncan's room leaves the audience in suspense til Macbeth tells his wife that he has killed Duncan.
We should remember that it is not just Shakespeare's language and his skill as a writer which is important; his staging and his skill as a dramatist are also important.