R' Yosef Alcastille, in a responsum quoted in Beis Hashem of the Shela"h, says that there is not, and cannot be, an answer to this question.
כי אם אתה נותן סיבה וטעם למה שרצה האדם בזה הדבר יותר מבזה, א"כ סיבה הניעה לרצונו שיבחר בזה יוזר מבזה.
As if you attribute a cause and a reason as to why a person has a will for this thing over that, if so the cause is what moved him to his will to choose this more than that.
Meaning, as much as there are factors that go into your decision and external things which may influence you, at the end of the day there is something which we cannot explain, that is beyond the factors which influence your decisions, that causes you to choose right or wrong.
This is really implicit in reward and punishment. If every decision you made was based entirely on the preponderance of factors leaning in one direction, and there was no "you" involved in making the decision, then you could hardly be held accountable. I once heard this nicely illustrated by R' Dovid Gottlieb. The Stoics (an ancient philosophic society) asked a challenge to the concept of free will. When a person makes a decision, practically how does it work? If there is a random mechanism which fires and decides yes or no at random, then the person is not really making a decision. If there is some internal calculus which quickly processes a number of factors and then makes the decision accordingly, then still the person is not making a decision - whoever placed the system of factors is making the decision. If there is an outside mechanism which is the catalysts for your decisions, then they aren't your decisions.
This is what מהר"י אלקאשטילא is addressing in pointing out that this is, indeed, something that we cannot identify, but it exists nonetheless.