So in everything, do to others what you would have them do to you, for this sums up the Law and the Prophets.-Matthew 7:12
This particular passage is sometimes referred to as the “Golden Rule”. But so often we misunderstand what Jesus is actually telling us to here. We think that Jesus is telling us that if we want someone to act in a certain way towards us, that we need to act in a certain way towards them. And in many ways that is true. But is not the point that Jesus is emphasizing here. Jesus is reemphasizing the point that he made earlier about loving everyone.
You have heard that it was said, “Love your neighbor and hate you enemy.” But I tell you love your enemies and pray for those who persecute you, that you may be children of your Father in heaven. He causes his sun to rise on the evil and the good, and sends rain on the righteous and the unrighteous. If you love those who love you, what reward will you get? Are not even the tax collectors doing that? And if you greet only your own people, what are you doing more than others? Do not even pagans do that? Be perfect, therefore, as your Heavenly Father is perfect.-Matthew 5:43-48 NIV
What this all boils down to is this: do to others the right thing not so that will do it to you, but because it is what God has commanded you do to and it shows those around you a perfect picture of God.
Hearing that Jesus had silenced the Sadducees, the Pharisees got together. One of them an expert in the law, tested him with this question: “Teacher, which is the greatest commandment in the Law?” Jesus replied: “‘Love the Lord your God with all your heart and with all your soul and with all your mind.’ This is the first and greatest commandment. And the second is like it: ‘Love your neighbor as yourself.’ All the Law and the Prophets hang on these two commandments.”-Matthew 22:34-40 NIV