Regarding diversity:
For realism.
A trader always brings and takes away products. Loading more things in origin city A, means the trader can sell more things in destination city B. The trader does not return with his benefits back to city A. He purchases exotic products in city B that he thinks he can sell back in city A, making a second profit when he's back. And back to his origin city, the trader will expend his money living in his city. The trader just cannot sell things to one city that already exist in the city.
A simple case. City A has 1 salt. City B has nothing. Then City B can buy salt to City A. A gains 1 gold for the trade scaled by city B size (more people, more merchandise can be bought), plus the same amount as the traders benefit, who stays at city A for a living.
Other case. City A has 1 salt. City B has 1 salt. No trading is possible.
Other case. City A has 1 salt. City B has 1 amber, 3 truffles. City A can sell its salt. City B can sell all of their goodies too. City B gets 4 gold, scaled by city A size. City A gets 1 gold scaled by city B size. City A also gets the sum of everything as the trader benefit.
For gameplay.
Cities that are far away normally don't have the same resources, so we can ignore that part. For simplicity, each city gains their number of improved resources, scaled by the other city size. And the origin city gains the sum of both values. After that, apply distance modifiers.
For example. City A: 10 pop, 3 resources. City B: 15 pop, 2 resources.
A base value = 3 * 1.5 = 4.5.
B base value = 2 * 1.0 = 2.0
Trader (from city A) earnings = 6.5
Distance modifier to trader earnings (say 75%) = 4.9
So A gains 9.4, and B gains 2
Other example. City A: 25 pop, 3 resources. City B: 10 pop, 6 resources.
A base value = 3 * 1.5 = 4.5
B base value = 6 * 2.5 = 15
Trader earnings = 19.5
Distance modifier (say 50% for a close route) = 9.7
A gains 14.2, and B gains 15.