Macbeth is a short, violent, and dark play. From the play's beginning, Shakespeare plunges his audience into a world of murder and conflict, and he underlines this by beginning the action on a battlefield. This violence, however, is not mere senseless action, and much of the play centers around the question of what is justifiable violence and what is not. By studying the characters of Macbeth and Macduff, we can surmise that Shakespeare condones violence conducted in the protection of the state, while he condemns violence done in the pursuit of arrogant self-interest.
At the beginning of the play, Macbeth is already a decorated general in the service of King Duncan. His peers shower him with praise in the opening scenes, honoring his recent deeds on the battlefield. Thus, Shakespeare implies that this kind of selfless violence, done to protect the state, is forgivable and even admirable. It acts as a foil for the rest of Macbeth's violent actions, including the murder of King Duncan, which are carried out to secure personal power. While Macbeth's deeds as a general were carried out for the good of the state, his later murders are done for personal gain, and Shakespeare condemns this brand of violence by rewarding Macbeth with a grisly death in the final scene.
Macduff's murder of Macbeth offers a rather more complicated side to this issue. On the one hand, Macduff is motivated purely out of revenge, as he aims to avenge his dead family members. However, in killing Macbeth, Macduff also rids Scotland of an evil tyrant. As such, though a considerable level of self-interest motivates Macduff's actions, he ultimately carries them out in defense of the greater good. As such, Shakespeare still maintains that violence, if done to protect the inhabitants of the state, is permissible.