The golden rule in the Bible is found in Matthew 7. A shorter version is recorded in Luke 6. It was given toward the end of Jesus' vast Sermon on the Mount that starts in Matthew 5:3 and ends in verse 27 of chapter 7. This golden precept in the King James translation is the following.
Therefore all things whatsoever ye would that men should do to you, do ye even so to them: for this is the law and the prophets (Matthew 7:12, KJV).
And as ye would that men should do to you, do ye also to them likewise (Luke 6:31, KJV).
A modern variation of the golden quote, not found in the KJV, is "Do unto others as you would have them do unto you."
Why Golden?
Why Matthew 7:12 is labeled the golden rule is unknown (Holman Bible Dictionary). The phrases' earliest use as a guiding principle, according to the Merriam-Webster Online Dictionary, was 1570 A.D. Despite its unknown origins, there are a few reasons why such a designation is nevertheless warranted.
Gold is something highly valuable, enduring and precious, like Jesus' beautiful words in Matthew 7:12 and Luke 6:31. His teaching in this verse is "golden" because it perfectly summarizes God's righteous character that is something we should strive for (Matthew 5:48).
Matthew 7:12 can rightfully be called a rule because it is a basic, common sense standard of behavior applicable to any human. Its "golden" teaching is endorsed by the world's four largest religions (Christianity, Islam, Hinduism and Buddhism) as well as Judaism and others. As a reflection of God's perfection, it can justifiably be considered a law of the universe as it always existed and will continue to do so into eternity.
By What Standard?
This teaching by Jesus does not allow us to treat others any way we choose as long as we would not mind being treated the same way. The world at the time of Noah was destroyed by the flood because people continually treated others sinfully and expected the same behavior toward themselves (Genesis 6:5).
The foundation of the golden maxim is both God's law (which Jesus did NOT come to destroy or remove, Matthew 5:17 - 18) and its full spiritual intent taught by Jesus (hence the word "therefore" at the beginning of Matthew 7:12). This means that how we ought to be treated, and how we should treat others, is firmly based on what the Bible states, both Old and New Testaments, are acceptable and right.
Why Follow It?
Why follow the golden rule? We should live by this precept because it ultimately produces the greatest good for everyone including ourselves. We should also follow it because God has made it abundantly clear that how we treat others is how he will treat us.
For example, one of the eight beatitudes declares the Eternal will be merciful to those who show mercy (Matthew 5:7). What is known as the Lord's Prayer asks our heavenly Father to forgive us only as we forgive others (Matthew 6:12, 14 - 15).
And do not judge others, so that you yourself will not be judged in any way. Do not condemn others, so that you will not be condemned in any way. Forgive, and you shall be forgiven (Luke 6:37, HBFV).
The golden rule and its "do unto others . . ." principle will be one of the foundational teachings promoted in God's kingdom when it is brought to the earth at Jesus' Second Coming!