These two sons of Duncan realize that their lives are in danger. They both leave the country which casts suspicion on both of them in their father's death. However, by leaving the country, they put themselves out of the reach of Macbeth, who surely would have killed them or had them executed for their father's death. Eventually, Macduff comes to see Malcolm, who has taken refuge in the court of the English king. Together, they are able to mount a defense against Macbeth.
In Act II, Scene 3, when Malcolm and Donalbain receive the news of their father's death, they realize their lives are in danger. Donalbain states:
What should be spoken here,
where our fate,
Hid in an auger-hole, may rush, and seize us?
Donalbain is aware that staying near Macbeth and others will not bring them any good; the murderer is still there, and they have good reason to fear for their lives. And they are right. Had they not decided to leave the country, Macbeth would surely kill them or have them executed. The deaths of Duncan, Banquo, Lady Macduff and her children certainly help solidify the claim that Macbeth would kill Duncan's children as well.
Malcolm states that it is easy to be among these men and pretend to feel sorrow over Duncan's death:
Let's not consort with them:
To show an unfelt sorrow is an office
Which the false man does easy.
Therefore, Malcolm and Donalbain decide that they will go their separate ways; Malcolm will flee to England, while his brother will escape to Ireland. Doing so will guarantee that the murderer will have a difficult time tracing them since they will be in different countries.
Towards the end of the play, Malcolm comes back to Scotland to fight with Macduff against Macbeth, while Donalbain does not return.