What is duty? Swami Vivekananda describes a duty as an act or work which bears no Karma - good or bad - and thus can help slow the cycle of suffering, and lead to freedom from Samsara. This is the "Karma Yoga," the Yoga by which we control our destiny.
Stick your finger in a glass of water and then pull it out: after a moment it will drip and dry; can you see where it was in the water, or even that the water was disturbed? This is your life's work. Though a person may accumulate many things in a lifetime, what they keep when they die is truly theirs. Duties are those actions which are done selflessly, without reward or punishment, fear or desire, without permanence, for their own sake. It is unmotivated and unpurposed - and both voluntarily and consciously undertaken.
Sometimes duty is confused with obligation. We have many obligations. We are obligated to society to dress ourselves before going outdoors, and to wear the appropriate clothing to our role in society. But this manner of dressing changes with time: our first President wore tights and high heels: yet a few generations later, and fashions change. And in other cultures, the President may wear something other than a business suit: a military uniform is not uncommon dress for a President. Which is right, or wrong? We have numerous religious obligations, as well: these too change with time and location. And it is good that religious practices change with time, what other purpose would there be in spiritual practice if we did not grow and improve? But it is inappropriate to describe one religious practice as right or wrong. None of these are duties: all these practices are done because they are believed to be the right thing to do, or to avoid doing what is wrong. They are done with some concept of purpose and reward.
Duty is also sometimes confused with custom. There are many customs, and they differ from place to place and time to time. Even in something as basic as marriage and family: is a marriage between one man and one woman? Between one man and many women? One woman and multiple men? Between individuals of the same sex? Or different species? What is "wrong" or "right" to us is not universally so; we should refrain from judgment of other customs because our own may prove to be equally shocking to those we might condemn. We abide by custom because we are "accustomed" to it by habit. This does not make it a duty, for a duty is done consciously.
Similarly, duty is not obedience, for it is voluntarily undertaken. Service in war is an occupation that requires following commands by superior officers - but this is not an act of duty. Not any more than obedience to law is a duty.
Swami Vivekananda says that the duties of the Brahmacharya are less difficult than that of the Sannyasa, and the duties of the Sannyasa are less difficult than that of the Vanaprastha, which are less difficult than that of the Grihastha.
There have been atrocities committed in the name of obedience, custom, and the obligations of religion and society. People have even killed each other to satisfy law. "But no duty is ugly, no duty is impure," teaches Swami Vivekananda. Those performing duty understand, "Let the end and the means be joined into one." The dutiful Grihastha is a teacher even to the Sannyasin: "When you are doing any work, do not think of anything beyond. Do it as worship, as the highest worship, and devote your whole life to it for the time being. My birth placed me in these circumstances and environments. In my childhood I learned the trade; I am unattached, and I try to do my duty well. I try to do my duty as a householder, and I try to do all I can to make my father and mother happy. I neither know your Yoga, nor have I become a Sannyasin, nor did I go out of the world into Vanaprastha; nevertheless, all that you have heard and seen has come to me through the unattached doing of the duty which belongs to my position."