The use of visions in Macbeth is first of all a very good stage technique which, like the soliloquy, allows the audience an insight into a character's mind (e.g. Lady Macbeth's troubled conscience as evidenced by the vision of blood on her hands, "Out, out damned spot;" Macbeth's vision of a "dagger of the mind").
Secondly, the visions also serve to show Macbeth's (and Lady Macbeth's) downfall. Macbeth sees a dagger, which becomes bloody; then he sees a ghost. The first vision is private. He is able to keep his thoughts hidden. The latter is public and his immediate court witness his troubled mind. He is able to dismiss the first -- indeed using that wonderful phrase to ask if the vision is a "dagger of the mind." He questions the vision. But when confronted with the vision of the ghost, he is unable to dismiss it willingly. It consumes him; he has fallen, and in a sense in the drama, there is no opportunity for redemption left him at that point.
The visions show Macbeth in relation to temptation and then in relation to sin entertained. He is able to withstand the temptation, and toy with it; but once having sinned, the consequence (and the vision) are irresistible.