If you want the best possible relationship:
- Settle nowhere close to them. (Make sure your borders don't reach them either)
- Constantly give them gifts.
- Make sure their army is bigger than yours.
- Let them do anything they want, allowing you to only have the "breadcrumbs"; essentially, anything that's left over (which would probably anger other states too anyway).
- Make sure you don't have good relationship with any city-states near them (even if they're near you too).
It is nearly impossible to do that if you're already mid-way through a game. The way that your 'reputation' works with other AIs is that if they can't do anything and you're in their way - They'll start to hate you. Even if you're their military supplier or the 'guy' who gave them (other nations) all the gold you earn etc.
There is no way to make AI players voluntarily want to ally with you, unless you do something that they like (ie. Go to war with someone they're at war with).
The way relationships with other states work is that you have to share a common goal with them in order to get 'on their good side'; be allies/friends.
Other than that - It's nearly impossible to get world peace (everyone allied with each other).
For some problems such as building wonders that they want to build (and already having built them), there's nothing you can do; nothing can be demolished (except for tile upgrades).
Example: I was a warmonger (had heaps of military units), but didn't use them to attack other nations. However, all the other nations except for one hate (and constantly denounce) me as they themselves were warmongers and was at war with another nation for constantly denouncing them.
There was no way I could improve my relationship. I've been accepting all their demands, gifted them everything, agreed to their wants in the world congress and everything for over 400 turns. Every time I improved my reputation with them (they start to like me), it went down again (they hated me more).
EDIT: The only way I could make them start 'liking' me was to destroy my huge army, which would leave me vulnerable to their attacks as they had a descent army themselves (around 10 units, compared to my 50+ units)