Meaning
When we return something which is equally valuable to what we got, we use this phrase.

Origin
In 1991 a thriller movie ‘The Silence of the Lambs’, starring Jodie Foster and Anthony Hopkins as Clarice Starling and Dr. Hannibal Lecter used this phrase as:
Hannibal Lecter: Plum Island Animal Disease Research Center. Sounds charming.
Clarice Starling: That’s only part of the island. There’s a very, very nice beach. Terns nest there. There’s beautiful…
Hannibal Lecter: Terns? If I help you, Clarice, it will be “turns” for us too. I tell you things, you tell me things. Not about this case, though. About yourself. Quid pro quo. Yes or no?

Though some phrases which had same meaning were into use from 16th century but this came in writing much later.