but it's not purely random They attack you when you're weak militarily, or when they want something you have. They don't randomly get pissed off at you, they get pissed when you're aggressive towards civs and city states. They also get mad when you expand too quickly and too close to them. However if you keep a decent sized army around and you are much less likely to be attacked. That doesn't mean you're entirely safe but it is a good deterrent. I've played a game until around the early Renaissance and didn't get declared on once. The only threat of attack I ever received was after I annexed a city state and lost a few units during the war (thus weakening my army). The enemy viewed me as a warmonger and saw that my army got weaker so they became more hostile towards me. I'm not sure about you but that sounds alot more logical and understandable than completely controlling my enemy's relationship towards me through a single situational and badly placed game mechanic like religion.