My textbook has the sentence: " 私は日曜日[に]国へ帰ります。" This means that に is optional, however, why is it optional, and how would you decide when to write/not write に. Thanks!
As for the "why" question - it's simply optional in the language, and that's just the way it is. Now the harder question is when and when not to omit. IN the given example, I would not omit, because it is formal and it sounds like something out of a politely written letter. IN those settings, you don't omit.
ON ther other hand, in a casual conversation, over phone or in person, you use omission by default: You might go じゃあオレ、先に家【に omitted】かえるからぁ～。ばいばい。 after you had a dinner with friends and you are letting them know you're bugging out and heading home know with implication that someone might join you at home later.
However, in formal writing, it's also possible to use the omission. IN that case, use a 、（てん）