Justice is about restoring order. And in a play such as Macbeth, there is a tyrant who has usurped the throne; he is not the rightful king, is not of the royal bloodline. Macbeth has stolen something sacred, since the divine right of kings, during the time of the Renaissance, is moral law. It's arguable, that Macbeth has committed one of the most heinous and sinful crimes that can be considered during Shakespeare's time. Macbeth's overambitious nature, along with his wife's, leads him down this path, and this theme of ambition driving man to his downfall and destruction leads to the necessity for justice to correct this dangerous and ambition and restore order.
The above answer explores the King seeking justice for the Thane of Cawdor's treachery and betrayal in siding with the Norweyans. The traitorous Thane, who is ambitious himself, being promised his own spoils, is sentenced to be beheaded and put on public display, which is still a sense of reminding others of the order of things, of who is in charge, to put it plainly. But let's also look at two other notions of justice that are connected to this idea of ambition.
Macbeth has murdered Macduff's family in an attempt to smote his enemies and retain the throne. He has sent assassins to kill Macduff himself, only to find that Macduff is not home, but has fled to join Malcolm in England who is readying an army to revolt against the tyrant King. With Macduff gone, the murderers to the Macduff's wife and childred and eliminate them. I'm arguing that this still stems from Macbeth's ambitious nature to control everything and eliminate any threats. The ambition even blinds Macbeth to murder innocent characters. But now it is up to Macduff to restore order, as he and Malcolm discuss what's to be done next after hearing of this murderous news. Malcolm states, "Be comforted. / Let's make us med'cines of our great revenge, / To cure this deadly grief," and later tells Macduff to "Dispute it like a man" (IV.3.213-215, 219). Malcolm understands that justice is up to these two men: one to avenge the death of his father and the other to avenge the murder of his family, both at the hands of the ambitious tyrant.
Finally, it is Macduff who must physically right the wrongs done to all of Scotland. In Act 5, it is Macduff who will clash swords with Macbeth on stage, referring to the tyrant as a "hell hound". Eventually, Macbeth's head is taken and placed upon the battlements as a testament to the entire country that order is restored, that justice has been served. The rightful King, Malcolm, is placed on the throne, all of the enemies of the state are rounded up and executed for their own ambitions (just as the Thane of Cawdor had been executed 4 acts earlier). Macduff has done the deed and now must recognize the Malcolm: "Hail! King! for so thou art: behold, where stands / Th' usurper's cursed head. The time is free" (V.8.54-55). Macduff explains that the country has been liberated, that deadly ambition has been beaten back and all is right again.
But this notion of justice and relation to ambition is a curious one. Justice is necessary only when something unfortunate, wrong, disorderly has been committed. Without misfortune and evil, there would be no need for Justice.