We use have/has to for laws, obligation and necessity.
Law: You have to stop for a red light.
Law: Steffi has to carry her ID.
Obligation: Sophie has to be home before 10PM.
Obligation: Students have to bring their laptops.
Necessity: Evan has to go to school every day.
Necessity: Students don't always have to make their homeworkd