Every well-written main character in fiction has a why. They may not be able to rationally explain it, but they have it. Often, though, they can explain it — if not completely then partly.
One important thing that stories and writers do with this is what I'm calling "set 'em up and knock 'em down." That is: You give a character some motivation or reason in one part of the story to do or not do something, then later you take it away.
There are tons of examples of this. For one, maybe you give your protagonist reasons not to go on an adventure, and then you take them away so they can go on the adventure. Or, you have a recurring villain, and you give them a short-term reason to team up with the heroes, taking it away once the goal is achieved — a great source of tension. Or, you have a rival, and eventually, you take away their reason for being a rival rather than an ally, or you weaken their reason for rivalry somehow.
This seems like a really useful idea to keep in mind if you are trying to plot or outline a scene or a story. If you have a scene in mind that you want to include, you can chain back from that to think about the reasons you are going to need to set up and knock down in earlier scenes to get there.
This is probably obvious to a lot of people. It wasn't obvious to me. I hadn't thought about it explicitly until recently, thinking about things like consequences in Inuyasha. I think I was a lot of the time working from this implicit belief that it's pointless to add a motivation if you're just going to knock it down later — like it's zero-sum, like the set up and knock down commute and cancel each other out. In hindsight, obviously that is silly — there are tons of stories that work on this principle! In fact it seems harder to name a story that doesn't use this principle than one that doesn't. This is the idea underlying a host of well-known popular tropes. Those tropes wouldn't work at all if this were true — they would be "anti-patterns," not tropes.
(Of course necessary caveats, don't go too crazy manipulative or you may have trouble with character. Et cetera.)