In act 2, scene 1, right before the dagger soliloquy, Macbeth tells his servant to tell Lady Macbeth to ring a bell when his drink is ready. It becomes clear that this is a pre-established signal to indicate when the king's grooms are passed out drunk. The drink is not for Macbeth after all, but for the grooms. With them passed out, Macbeth can go ahead and murder King Duncan without witnesses.
At the end of the scene, we hear a bell sound off stage. This is the sound that Macbeth has been waiting for as it signals that it is time to commit the murder. In Shakespeare's day, bells often carried the connotation of death and misfortune. Shakespeare likely chose the ringing of the bell as Macbeth's signal purposefully in order to allude to the ghastly nature of the crime about to be committed.
Macbeth recognizes the sound at once and exits saying:
"I go, and it is done; the bell invites me.
Hear it not, Duncan; for it is a knell
That summons thee to heaven or to hell."