John 4:4 begins with the Greek word "edei" (meaning: It is necessary) implying that Jesus had to go through Samaria. What situation made it necessary for Jesus to travel through Samaria.
It wasn't necessary in the directional sense (physical sense). It was necessary in the spiritual sense. He was led to go there to meet the woman at the well. A similar example to this is Philip goes and stands by the chariot, except in this case, the words are used "The Spirit said to Philip" (Acts 8:29). When we do things in the physical realm there are not such unusual events. Similarly, Jesus going to see Lazarus... If you work out the 4 days from the time he heard the news, and the journey time, you see that he let Lazarus die purposely. This is difficult for people to understand, but in the large scheme of things its pretty simple really.