Every time I play a game in Crusader Kings 2, my vassals rebel

Go to the Intrigue screen, then look at the Threats tab at the bottom. This gives you a list of nobles, along with the odds of their rebelling per year. You want these numbers to be as low as possible, of course! Mouse over the "rebellion chance" to see why they're rebelling. The usual cause is a low opinion of you, but other factors can come in, like their relative power to you or distance to your capital. Make sure that you're more powerful than your vassals (a large, demense full of well-developed counties will help), and in their front yards, and they'll stay in line.

Nobles usually rebel because they don't like you. To make them stop rebelling, get them to like you.

A noble's info screen will have their opinion of you; mouse over that number (if they're threatening to rebel, it's probably negative!), and see why they don't like you. Look at the reasons, and see if you can fix them. (They have a 60% chance to rebel, and they covet your lands? It might be worthwhile to give them one of the titles they want. That will remove a -25 penalty, and give them a +20 or better bonus.) Note that once somebody rebels, all of your nobles get a penalty to their opinion of you. If one guy is rebelling, expect him to tempt more people to rebel.

Ways to increase a noble's opinion of you:

  • Give them an honorary title; these give +10 or so opinion, but don't give Cupbearer to somebody who might decide to assassinate you. You have six of these to hand out (plus a seventh, Court Jester, that makes them dislike you).
  • Give them a gift; the cost depends on their best title (or maybe total economy?), so bribing a powerful Duke is more expensive than bribing a Mayor. Gifts are much more effective against Greedy people. Can be up to +60 opinion, but is usually lower.
  • Send your councilors on missions to the vassal's capitol county. (Their capital will be their primary county title: the first coat of arms in their titles list and where their shield appears on the map.) Your chancellor can go on a mission to "Improve diplomatic relations"; when successful, this will grant a +30 bonus for 4 years, and it can stack multiple times. If you need to placate a religious vassal (e.g. bishop), send your Chaplain to Improve Religious Relations in their county.
  • (Not always applicable) If they have an Ambition To Marry (or be Marshal, or some other thing), help them achieve it. Do not appoint a semi-rebellious noble to be your Spymaster. They may decide to kill you, doubly so if they have a claim on anything of yours, and they'll be in the best possible place to do it.
  • (Not always applicable) Let them educate one of your children, for +20 opinion.
  • (Not always applicable, long term) Educate their heir. They won't agree to this if their opinion of you is lower than +20, so you'll have to boost it up with other ways. But educating the heir can allows you to prevent them from getting the Ambitious trait and convert them to your culture. When the child becomes of age, they will get a +25 opinion bonus of their mentor for 20 years.
  • (Time-consuming, expensive, not always easy) Press one of their claims for them, by going to war against somebody else to claim something, and using that noble's claim as a Casus Belli. Your kingdom gets bigger, and they get +100 to their opinion of you. Of course, the war may take so long that your vassal rebels before it's over.
  • (Erodes your power base) Transfer a vassal to them for +20 opinion. Alternatively, transfer your rebellious vassal to someone more loyal. (Only works when they can be a vassal; you can't transfer your Super-Duke-Of-Rebelliousness to another of your Dukes.)
  • (Erodes your power base) Give them one of your titles. If they covet a title, it's a -25 opinion, so when you give them a title, it will remove the -25 and grant at least +20, for a total of +45 opinion.

Ways to remove them as a threat:

  • (Risky, may encourage other rebellions) Find a valid excuse to arrest them. If it works, take a title from them so their rebellion won't be as powerful — and keep them in your dungeon, so they can't rebel. If arresting fails, then crush their armies and siege their holdings, then take a title from them after they surrender. If you don't have a valid excuse to arrest him, then assign your spymaster to look for plots in his capital; if he dislikes you, he probably has a plot going against you and the spymaster will find it (and then you can arrest him legally).
  • (Catholics only, costs piety, requires good opinion from pope or antipope) Get them excommunicated, then arrest them. This works even if you don't have a valid reason to imprison them; nobody cares what happens to excommunicated people. You can even execute them (does the vassal's heir love you more than the vassal?), but arrested people are pretty harmless.
  • (Risky, may encourage other rebellions) Let them rebel, and crush them quickly. Mercenaries can help with this.
  • (Time-consuming, risky, heir may be just as bad) Plot to kill them. It will be time-consuming to gather plot power, and then there will be a delay—on the order of months—before each assassination attempt occurs. (On the plus side, you'll retry failed assassinations automatically.) There's also the risk that one of your fellow plotters will spill the beans, which will give them -100 opinion of you and usually make your target respond in kind and plot to kill you.

    Check your major opinion penalties before you plot to kill: if the main penalties are things like "Too many duchies" or "Desires that shiny county of yours", then these will be inherited by your target's heir and you'll have exactly the same problems after the unfortunate demise. But if your target's problems are things like "Ambitious" or "Greedy vs. Honest", then it's a personal problem and the heir should be different. (Go check the heir to make sure he's actually different – children raised by their parents often have similar personality traits.)

  • (Lowers opinion further) Your Spymaster can "Scheme" in your target's capitol, which can give you an event that discourages vassals from factionalism. This gives a -10 opinion penalty, but if it succeeds, that vassal cannot found or join a faction for 10 years. This is useful if the noble in question doesn't worry you, but having him join a faction does, but you'll have to keep repeating it from time to time.
  • (Makes you sad) As a last resort, simply grant them independence. If your biggest problem is one vassal, and his rebellion drags your entire country into a civil war, just give him what he wants and throw him out of the kingdom. Perhaps you can offer his heir vassalization later, or simply conquer him.

How to organize your kingdom to reduce rebellions

Your personal demesne should consist of two duchies, plus all of the counties in those duchies (or less, if your demesne limit is lower; use larger duchies if you have a large demense. Tangentially, a high Stewardship will increase your demense limit and also improve your income.). This means several things:

  1. Your dukes don't desire your counties (because you're the owner of the duchy, not the duke)
  2. Your counts don't desire your duchies. (After a few generations, it's entirely possible that some counts will inter-marry enough to own a majority of the counties in your duchy; then you get an opinion penalty with them, because they want the duchy.)
  3. Your personal power is concentrated, so you can mobilize your troops into a single large army quickly.
  4. Vassals get an opinion penalty of -10 per duchy after the second, so owning a third duchy can cause problems.

To avoid Super-Dukes (and thus make rebellions hurt much less), try the following:

  1. Make sure each Duke only owns one (or just a few) counties. Give the other counties in their duchy to various other people, so that you don't have to deal with the opinion penalties. (This won't work forever; they'll be marrying and building their own little fiefs, and Super-Dukes can arise naturally after several generations.)
  2. Spread out each Duke's demesne. It's easier to beat a duke who owns a county in Spain, a county in England, and a county in Jerusalem than it is to beat a duke who owns three counties in Ireland. Ideally, these counties should be in duchies you don't hold, so you'll never need to worry about him desiring your duchies.
  3. When a Super-Duke does arise, monitor them more carefully. Pull out all the stops to keep them happy and groom their heir. If that doesn't work, prepare for or instigate a rebellion and split up their titles when you win.

To really reduce the chance of rebellion, make sure your dukes have their capitals near your capital; "distance to capital" can be a major contributor to rebellions. To set this up, start with a Courtier and give them a county near your capital; they'll set their capital there, and have a lower chance of rebellion. Now give them a duchy (and possibly other lands); their capital shouldn't move. Alternatively, you can move your capital to a more-central location to keep it roughly equally close to everyone.

(Note: I haven't tested the last advice about forcing a vassal to have a capital somewhere near you. You are permitted to move your capital once per generation; I'm not sure if — or why — your vassals, as AI players, might move their capital.)