Student or Learner
You didn't have to come with her.
You didn't have to do anything.
I want to understand how does "have" function in these sentences?
I understand "have" is used as a main verb and also to show the obligation. Am I correct?
"Have to" has the same meaning the same as "must". However, we don't use any version of "must" in negative sentences.
You have to come with me = You must come with me.
You don't have to come with me. (There is no way to say this using "must")
Remember - if you don't use correct capitalisation, punctuation and spacing, anything you write will be incorrect.