Context: This quotation is from that part of Jesus' teaching traditionally called "the Sermon on the Mount." Jesus first gives expression to the "Beatitudes," then assures His hearers that He has not "come to destroy the law;" he has come "to fulfill." He teaches them to pray, giving as a model "The Lord's Prayer," warns against ostentatious religious observances and against laying up "treasures upon earth." This last injunction leads naturally to the warning against attempting to love both God and material wealth (Mammon), which Jesus puts into the form of a vivid metaphor:
No man can serve two masters: for either he will hate the one, and love the other; or else he will hold to the one, and despise the other. Ye cannot serve God and mammon.