Stop, please stop. The rivalry system is not fine its broken. Mark my words, rivalry will either be removed completely or get a massive overhaul and that will show its *not* fine.
There should be logic in strategy gaming, and rivalry is not logical at all.
There is usually logic behind rivalries. Just because you don't understand it doesn't mean there is no logic at all. I personally have no problem when nations decide to rival me. Rivalry basically means they see you as a competitor, and as I've shown in my screenshots friendship/alliance can prevent rivalry to a significant extent. France not rivaling a fully fledged Germany? Why not? The attitudes used to fluctuate more, and people complained the allies turned rivals or hostile all too often. So they made the attitudes a bit less likely to change, and you can now have permanent allies next to your border.
1. You're about the even sized nation. Small nations usually rival other small ones, big ones usually rival big ones. Let's say you're playing Denmark and Castile decides to rival you and you're left with 'wtf?' expression. Castile sees you either as an equal power, or someone to surpass in the future, or a distant potential threat rising which, if left unchecked, can be problem to itself.
2. You're their trade competitor. I've had OPMs rivaling me while I was much, much larger. An OPM Moldavia rivaled my Asia-spanning Candar, and an OPM Zhou did to my Champassak which pretty much unified all the mainland Southeast Asia, for example. They presumably did this in order to increase embargo efficiency in their own trade node.
3. They do not want to have a diplomatic relationship with you. They don't see you as an immediate threat to their independence, but as a potentially dangerous enemy, and chose not to antagonize nor to have relationships with you, such as royal marriage. In my England > HYW > HRE, Spain never ceased to rival me to the very end, because we shared a dynasty. Portugal fell to junior partner, and Spain didn't want it to happen to it.
4. Just like a human player would do, the AI nations would rather be surrounded by smaller nations than face a larger or equal sized nation nearby. So, while they do not want to conquer your lands directly (that's hostile attitude), they'd like to cut you down a bit to feel safer. Say, you're playing as Austria. You're currently allied to France. France is gobbling up provinces Brittany, Provence and Burgundy. You would feel worrisome - THIS is the moment an AI Austria would rival France. You might be friends now, but in the long run you don't want France to grow too big.
5. Now, this might be an unfortunate side-effect of a game, but there might not be any other viable nation left to rival. In my England > HRE, there weren't so many nations left in Europe at all in the late game. Whoever survived either rivaled me (Spain still had the size to do so) or each other. Hungary rivaled Prussia, Lithuania and Poland because there were no other Eastern European nations left at the moment even though Hungary was completely landlocked within my borders.
6. Again, this can be another side-effect of being a game, but the AIs can be very slow to change their attitude. Austria rivaled me in the Ulm campaign (screenshots on the first page) fairly early and they never removed it until I demanded total annexation. They don't flip their attitudes too often because there were complaints that they did so too often and randomly. Once they rival you, it can be hard to change back. They might, they might not, and it's up to them whether they want something out of you or not.
7. They want the enemy of enemy bonus.
How do you change their attitudes? Usually you can't. You can improve relations all you want, but they're meant to be resisting your efforts otherwise the game will become too easy - their strategic interest always takes precedent over the "opinion."
By the way, if you really want to see what an AI nation thinks of you, you need to look at your opinion of them: say, you're France, and you want to ally Austria. You improve their opinion of you to +100. You can't ally them because "you don't like them." The truth is that Austria doesn't give you a damn and is not interested in alliances, and therefore makes no effort to improve your opinion of Austria. There are limited way to improve your opinion of a target country (like military access or shared rivalry) to get around this, but the point is that you can't just send a diplomat to change the AI attitude towards you. The opposite happens as well: if you're France, and tiny Alsace improves your relationships, will you be kind to be their protecting ally instead of conquering them? It's perfectly normal for an AI nation to have +100 opinion and still hostile/rival just as it is normal for you to be that way. Sure, you want to be our friend and buy us some beer, but I'd still rather have your provinces than you as my friend.
Likewise, "random" hostilities are also perfectly normal. You look at the map, and you wonder who you should invade first. Hmmm... maybe I want to take this bit of Poland next. Sorry Poland, you've done nothing against me and in fact I kind of like you, but I want your land. The AIs do exactly the same thing. If an AI turns hostile, they want your province(s). They may or may not act on it, and they may reconsider and change their ambition - then they're not hostile anymore. If Poland suddenly changes from hostile to friendly to your Brandenburg, it means they changed their plan: they want to go after Bohemia and now they think you might be a useful ally. At least, unlike humans, the AIs give you a signal that you're their conquest target and that's a nice advantage you have as a human.
There was a dev response a while ago (I think it was Wiz) to a similar complaint - the OP of that thread, Brandenburg, allied Bohemia and conquered Neumark. Bohemia broke the alliance and turned hostile, and the OP complained about it. The dev answer was simple: Bohemia wanted Neumark as well, and while the Bohemia AI would appreciate Brandenburg declaring war on Teutonic Order, but still they want the province.
Well, in the end, if you really have problems with the AI attitudes, play a non-ironman game with the console command 'aiview.' This will allow you to see what the AI thinks of you and other nations by hovering mouse over the sheild on the diplomacy screen. It shows who they think of as friends, rivals, enemies, and what provinces they want to conquer, where they want to colonize, etc. Their conquest wishlist is often fairly extensive. AIs have their ambitions just as you do.