On higher difficulties the gap between an AI's early army and a player's military police tends to be the largest, and relative strength is one consideration when AIs decide who to plot on. It means the player is a tempting target, but not to the point one should expect to be declared on every single game.
Being 100% safe from DoWs would mean getting every AI to Friendly before they could start plotting war on you, which is not feasible. That said if you have (for example) Shaka next to you, you can gift him a city that ends up giving him border tension with another neighbour. Even AIs that can plot war at Pleased still have a very significant chance to not plot war on someone they're pleased with, and extra border tension will pull an AI's attention further away from you. It's not a guarantee, but it's better than nothing.
Beyond that you have to play the diplo game correctly - adopt the right religion if any, strategically give in to demands, trade or even give away resources purely to build positive relations, same with maybe not getting the most you can out of a tech trade and/or not trading with someone's worst enemy, etc. It's one of those aspects of the game you really don't have to be particularly effective with on lower difficulty levels to pull off a win, but on higher difficulties, it's life or death.