The first and most important point to keep vassals happy is to check de jure setup: do you own counties, or do you have direct vassals that a duke/king vassal might want (ie those in his de jure demesne)? In long games, there are often counts/dukes that win independance wars against their de jure liege, so you become their liege. You usually get no warning and a permamnent -25 modifier until you stransfer that vassal back or give the county. Sometimes it can even happen to baronnies, especially when you personnaly land courtiers: if part of their family is made up of counts/dukes, through inheritance you can end up with a baronny in Germany being the vassal of a duke in Navarra. Good luck finding that if you don't check opinion modifiers...
Otherwise, before inheritance (old 50+ grandpa):
- save money: if war breaks out after inheritance, you will want merc bands
- don't get involved in tough war: nothing like dying in a war against the HRE to be in trouble
- do your best to convert rulers not of your faith: old rulers are well liked so it's the best time to convert people for easier inheritance (gift gold if needed,...); opinion threshold for conversion acceptance is 30 so you can easily guess if it will work
- marry your daughters for alliances with foreign powers. Even if you don't have use for them against foreigners, it's a cheap way to get away from civil wars (if they are reluctant to join your war: gift gold)
After inheritance:
- make yourself more threatening in small realms (more troops: higher martial skill so hunting or war focus) or more friendly in large realms (more diplomacy: family or carousing focus; if carousing, invite your most powerful vassals and get friends for life...); marry a high diplomacy wife if possible; high martial wife however won't increase levies
- don't set plots to auto-end: let vassals plot giving you a reason to imprison those in your way when needed
- don't go to war: it depletes your levies which makes revolts more likely; defensive war are fine because you get opinion bonus in those
- give away minor titles: focus first on vassals that like you; going from say 0 opinion to 20 will allow you to get a few more troops, but won't prevent the vassal from joining factions
- have marshal train troops in your best holding: more troops discourages factions from giving you ultimatum
- make powerful vassals councilors (fulfil their ambitions); you can appoint more competent councilors after the inheritance crisis if you feel like
- if you have imprisonned vassal, ruler changed so opinion did as well... While imprisonned, they will hate you; they won't revolt for sure, but won't provide levies either. Sometimes it's better to keep them imprisonned if they still hate you; otherwise, releasing them is worth +50 opinion (merciful and no more imprisonned modifier)
- if you can create titles, now is the time, gifting them is an easy way to keep a vassal in check; on top you can transfer unruly counts/dukes to dukes/king and they won't be able to join factions against you anymore
- if there are still dangerous factions: gift gold to the most powerful vassals... 150 gold to keep two powerful duke loyal can be enough to avoid a rebelion that would cost you much more in raised levies upkeep in the end...
- extreme measure: imprison your most powerful vassal and eat tyranny... The others might hate you, but if they don't have the power to challenge you, you'll get away with it
There's more that I can't think of right now but if you do all this very few revolts should threaten you.