Obligation: must I, or is it optional?
〜なければならない expresses a requirement, while 〜なくてもいい says that something is not necessary. Interpret these negative-looking forms as complete expressions.
Express a requirement
宿題を出さなければなりません。 means 'I must submit the homework.' Replace ない in 出さない with なければ and add なりません. The final ません does not make this a prohibition on submitting it.
明日までに出さなければなりません adds a deadline: it must be submitted by tomorrow. The grammatical form does not prove the source of a rule, so check who is imposing the requirement in real instructions.
Recognize related forms
〜ないといけません also expresses a requirement. 早く帰らないといけません。 means 'I have to go home early.' Once the meaning is clear, notice how the pattern is shortened in conversation.
Conversational 帰らなきゃ or 帰らないと can leave the rest of an obligation expression unsaid. However, not every ないと expresses obligation; use context to distinguish a conditional clause from a shortened sentence ending.
Remove the requirement
明日は来なくてもいいです。 means 'You do not have to come tomorrow.' Replace ない in 来ない(こない) with なくてもいい. This removes the requirement to come.
Sort examples into three groups: required, optional, and prohibited. If you put なくてもいい under prohibited, revisit the contrast: allowing someone not to act is different from forbidding the action.
Check: How do 来なければなりません and 来なくてもいいです differ?
Show the answer and why
The first requires someone to come. The second says they need not come; it does not by itself forbid coming.

