In Act 4, Scene 3, Malcolm asks Macduff this very same question. He does not understand why he left his wife and children unprotected. Unfortunately, Macduff does not provide any answer, so we cannot rely on the text for some explicit evidence. However, there are some implicit clues in the play which can potentially explain the reason for his flight.
Firstly, Macduff leaves his family because he is deeply perturbed that his beloved Scotland keeps suffering under the tyrannical rule of Macbeth. His love towards his country is the primary reason he has to leave his family:
Bleed, bleed, poor country!
Great tyranny! lay thou thy basis sure,
For goodness dare not cheque thee: wear thou
The title is affeer'd!
He is disillusioned that no one good and virtuous will stand up to Macbeth, so we may interpret this as his clear desire that he is ready to confront Macbeth with the potential help of Malcolm.
Secondly, in Act 4, Scene 2, when Lady Macduff accuses her husband of betrayal, Ross proclaims that it is not certain whether he left out of wisdom or fear:
You know not
Whether it was his wisdom or his fear.
This can be interpreted in various ways. It could be both fear and wisdom motivating Macduff to leave his family. He may fear that his country will suffer even more if he does not do anything to prevent that. And he may also find it wise to try to persuade other brave and virtuous people to fight against cruel Macbeth.
Thirdly, we may assume that Macduff also leaves his family because he thinks they will not be maltreated by Macbeth. This can be explained by the textual evidence we gain from Act 4, Scene 3, when Ross announces that his family has been murdered. Macduff is completely astonished to find out about this. This display of shock and disbelief may support the claim that he thought his family would be safe:
My children too? My wife kill'd too?...All my pretty ones?
Did you say all? O hell-kite! All?
What, all my pretty chickens and their dam
At one fell swoop?
He then announces that he cannot believe that his most precious things have been taken away:
I must also feel it as a man.I cannot but remember such things wereThat were most precious to me. Did heaven look on,And would not take their part?