This isn’t the only way, but it’s a good one.
First, you give your main character something to want.
Next (this bit of insight courtesy of Elizabeth Bear), you figure out what it is that your main character actually needs.
Then you build your plot on the tension between the two.