The appropriateness of this prophecy at this point becomes clear when we understand how the rejection of their Messiah was linked to the ultimate rejection of the nation and the national covenant by God. Zechariah encapsulates the contempt which the nation showed for the one sent from heaven whom they should have valued above every other.
Matthew 27:9 in quoting this passage refers it not to Zechariah but to Jeremiah. William Hendriksen considers several solutions to this problem, most of which he rejects, and explains it as a case of a New Testament quotation of two prophecies combined (Zechariah 11:12-13 and Jeremiah 19) only one of which (the major prophet) is mentioned by Matthew.