If something is done unduly, it's done out of proportion with what's reasonable or right. If you're unduly treated, you're not treated in the way you deserve to be.
Duly comes from the late 14th century duweliche meaning "rightly, properly." The prefix un-, meaning "not" of course reverses that meaning so with unduly we get "not rightly or properly." You might become unduly angry with a toddler for tracking mud into the house. Unduly can also mean "excessively." Worrying unduly about the future can be paralyzing. Sometimes it's good to take the days as they come.