He was trying to set a better example of how Jews should treat non-Jews.
Bummer. Agreement didn't last long.
Have you read the story in context? Jesus wasn't being nice, He was telling the Samaritan that the day was coming when it wouldn't only be Jews worshiping God in the Temple but all people worshiping in all places (in Spirit and Truth).