HE knew what they needed, yet HE knew what was to come as well.
from David Guzik's commentary at Biblos.com:
(Mark 6) The multitudes saw them departing, and many knew Him and ran there on foot from all the cities: It’s easy to think that the multitude was nothing but rude and demanding. The disciples wanted to send them away (Mark 6:36), but Jesus was moved with compassion for them.
i. The disciples often saw the crowds as work, and as constant demands, especially at a time like this when their well-deserved rest was interrupted by the multitude. But Jesus saw them and was moved with compassion. Each face reflected a need, a hunger, or a hurt. Being a thoroughly others-centered person, Jesus cared more about the needs of someone else than His own needs.