Good question! To find the answer, we can look at David's own words contained in his narrative of chapter one. They give us much insight into the reasons behind his decision to leave home. He says, "I was seventeen years old, and until then had lived all my life in the village of Essendean, in the lowlands of Scotland. On that day, I locked the door of my childhood home for the last time. My father, a schoolmaster in the village, had been dead for three weeks, and it was time for me to leave home and look for work."
Though David appears to have enjoyed his childhood in Essendean, he realizes upon losing his remaining parent in death that there is now little keeping him there and no longer any real reason for him to stay. He would be no closer in spirit to his deceased family in Essendean than he would anywhere. That, coupled with the reasoning that he may make his own fortune elsewhere, are the two main reasons David decides to leave home.
Later in that same chapter, as David begins to leave, he meets the minister, Mr. Campbell, on the road. As they walk together, Mr. Campbell explains to David that his late father had wished him to go to the house of Shaws, which is near Cramond (David’s father’s home) to deliver a letter to an old friend there. The minister reasons that if David is not well received there, he can always come home again. So, to add to the reasons listed above, David now has another reason to leave Essendean: an exciting two-day journey to his father’s hometown.