礼 = 礼物，礼数，礼貌，courtesy, etiquette
尚 = 注重，demand, require
往来 = 来来往往，to and fro
礼尚往来 literally means courtesy or etiquette demands reciprocity. If you are polite to me, I will be polite to you too. Nowadays, 礼尚往来 also means deal with someone as he deals with you. If someone treats you bad, you can use 礼尚往来 to treat him bad too. From the point of view of 礼尚往来, it is okay to “revenge”.