In Act 1, Scene 4, Duncan announces that he is making Malcolm the Prince of Cumberland, which means the young man is heir to his throne.
And you whose places are the nearest, know
We will establish our estate upon
Our eldest, Malcolm, whom we name hereafter
The Prince of Cumberland
In this same scene, immediately after hearing Duncan's proclamation, Macbeth says to himself:
(aside) The prince of Cumberland! That is a step
On which I must fall down, or else o'erleap,
For in my way it lies. Stars, hide your fires;
Let not light see my black and deep desires.
The eye wink at the hand, yet let that be
Which the eye fears, when it is done, to see.
Shakespeare inserts these lines because he just does not want to deal with the question of what Macbeth intends to do about Malcolm and Donalbain, both of whom stand ahead of him in the line of succession, and the elder of whom has been officially and publicly acknowledged as next in line by his father the King. The most important line in the passage quoted above is: "Let not light see my black and deep desires." Macbeth is saying, in effect, that his plans regarding Malcolm and Donalbain are made but that they will remain completely hidden until he has disposed of their father. The passage also suggests that Macbeth doesn't like to think about killing a couple of young boys. This is Shakespeare's way of dealing with an extremely complex matter by "shelving it," so to speak, "by putting it in the closet" with the intention of dealing with it later.
Shakespeare already has too much to deal with in dramatizing the murder of Duncan. Probably when he was writing the play he told himself he would worry about what to do with the two sons after he had written everything up to Duncan's murder and Macduff's discovery of the body. In other words, Shakespeare himself didn't know what Macbeth intended to do about Malcolm and Donalbain, but he pretends in the lines quoted above that Macbeth and his wife have discussed the matter thoroughly--as well they should have done!--and that they have a plan.
Shakespeare seems to have written his plays under time pressure and to have relied on inspiration, luck, and what he himself called "the virtue of necessity" to help him out in dealing with the problems he himself had created earlier. Shakespeare knew he was a genius and that he could always come up with a solution to a plot problem if he found that he had painted himself into a corner, so to speak.
Then Shakespeare has Malcolm and Donalbain decide to flee for their lives. (It seems possible that Shakespeare himself did not know the boys were going to flee when he was writing the first act and that this idea occurred to him only when he had to get around to writing the second act. Obviously it would have occurred to both of Duncan's sons that whoever killed their father would be after them next! They probably suspect Macbeth but also suspect that he might be in a conspiracy with other thanes who are present in Macbeth's castle.) This development is something Macbeth could not have foreseen, but it enables him to pin their father's murder on the boys and "o'erleap" both of them to become king.
That was the best idea that Shakespeare could come up with. The only alternative would have been to have Macbeth and his wife kill all three of their guests--Duncan, Malcolm, and Donalbain. And Shakespeare did not want to do that for many reasons. For one thing, he wanted Malcolm to raise an army and come back to claim the throne. For another, it just seemed unworkable to stage three murders in one night when it was complicated enough to stage even the one. He dismisses any possibility of Macbeth going on to kill the boys in their beds by creating voices, knocking at the gate, and giving Macbeth a sort of nervous breakdown. And for another reason, Shakespeare wanted his audience to feel at least a little sympathy for Macbeth. The audience would lose all sympathy for him if he even talked about murdering a couple of innocent young boys in their sleep.
There are probably many other reasons why Shakespeare virtually ignored the question of what Macbeth planned to do with Malcolm and Donalbain after killing their father. One other important reason is that Shakespeare was more or less stuck with facts of history. He just couldn't kill Malcolm if Malcolm hadn't really been killed by Macbeth in actual historical fact. Besides that, how would Shakespeare end his play? He had to have somebody come to Scotland with an army and dethrone Macbeth.