Self esteem is required for motivation. The role of self esteem, or more specifically the self esteem we feel about ourselves in specific fields is ingrained in motivation to pursue values in that field.
The reason we are built this way is because it serves our survival. For example: Suppose you're building a house with your own hands, but you know from experience that you are bad with hammering nails to the beams, you feel lack of confidence in that field: this serves to protect you from the damage you may cause (to your life and your values). Your recognition of your own ability in that field determines your emotional motivation to pursue it. On the other hand, if you're good with hunting animals or dancing, you have high confidence in your ability to pursue that value, you'd feel motivation to pursue it. When you succeed, it reinforces your confidence, and also serves as a reward. So self esteem is both a requirement and a reward for action.
This mechanism can work against you (when a mistake is involved): one example is insecurity with "hitting on" women. In this case, the mechanism of confidence<-->motivation prevents you from not hammering nails into your hands, but potentially (if a mistake is involved) also to be too afraid to hit on women or go after something you desire.
An example of that would be someone who expects himself to succeed at something right away without a process of learning. When he would fail (and he would, since learning is always required), he would get a sense of insecurity which would dismotivate him from pursuing that activity in the future. And it would be a false conclusion about his own ability.
Self-esteem is a general form of confidence: it does not apply to the ability to achieve values in a specific field, but to living as a whole (to your ability to live). It primarily comes from how one's actions and their result stand in relation to one's principles. Confidence in many small fields integrates itself in our mind to self esteem as a total sum.
Achieving confidence depends on achieving one's goals, and achieving one's goals depend on one's principles (among other things).
For example, great entrepreneurs like Herbert Dow,were guided by the principle of making a living by means of creating new products, and doing it well. Dow held this principles not as a mere intellectual idea, but as a passion for creation. He was also rational - never overlooking facts, and he had the correct principles in economics. As a result, he was successful. He was confident, and his confidence grew with his success.
His self esteem was high because he had the right principles for living, and throughout his life - his actions matched his principles.
To the extent a person conceptualizes certain virtues as practical to his life, his self esteem will depend on the relation between his actions and what he perceives as virtues.
If he comes to the wrong conclusions, he will not be able to achieve his goals, and he will become insecure the more years go by.
For example, if someone believes in mystical powers, and he thinks a man's worth is measured by his ability to possess mystical powers - he will fail time and time again in achieving his goal. He may wish for a red traffic light to turn green, but it won't in most times. He may try to guess your astrology sign, but fail most of the time. And so on. Eventually, he will not be able to achieve self esteem because his principles and ideas are not in line with reality.
Human beings think in principles. some animals learn from experience and probability (for example, a stick can pull a banana in certain situations). Human beings form ideas, concepts and principles to condense our knowledge.
Likewise, we use principles to guide our actions, and how we live.
And this is why self esteem depends on principles, and the relation of one's actions and their success to one's principles.