In order to discern, we have to be detached. Why? First of all, having a pure heart, or a heart detached from temporal and limited goods, enables us to have the spiritual vision by which we can see God's will. "Blessed are the pure in heart, for they shall see God." While this primarily pertains to future happiness with God–"they shall see God"–it begins also now, in the living knowledge that springs from divine love. A heart attached to temporal goods hinders this perception of divine light. St. Alphonsus says that if we want to know what state of life God wants us in, we have to pray for God to show us. But he goes on to say:
To have this light [from God], you must pray to him with indifference. He who prays to God to enlighten him in regard to a state of life, but without indifference, and who, instead of conforming to the divine will, would sooner have God conform to his will, is like a pilot that pretends to wish his ship to advance, but in reality does not want it to: he throws his anchor into the sea, and then unfurls his sails. God neither gives light nor speaks his word to such persons.
If we are set upon what we want to do, even before we begin the process of discernment, then (in most cases) we will be inclined to judge accordingly, and see our own attachment to what we want to do as an indication of God's will. (A few persons may from the outset understand vocation as something essentially contrary to what one wants, and so be inclined to take their desire or attachment as a sign that it is not God's will. This happens for the lesser part, and it is also unhelpful.)
Moreover, if we are attached to some way of living, we may fail to carry out what we perceive to be the will of God, and then discernment is in vain. "Do you not know that in a race all the runners compete, but only one receives the prize?" (1 Cor 9:24) It is not enough to find God's will, but we have to do it, and that means denying our own will, in the sense of taking God's will over our own. "Any man would come after me, let him deny himself and take up his cross and follow me" (Mat 16:24).