One of my readers, Graham, suggested this troublesome pair – I always l like to receive suggestions of pairs to write about, so do drop me a line if you’ve checked the index first and I haven’t written about your favourite!
Formally is an adverb formed from the adjective formal, and means being done by the rules of convention or etiquette, officially recognised, with a conventional structure, form or set of rules. “He replied formally to her gilt-edged invitation”, “I was dressed formally as it was a high-class event run by the establishment!.
Formerly is an adverb that means in the past; before whatever is being discussed now.
“Formerly, for example in the 19th century, social visits were done much more formally, according to established rules and customs. Now everything is much more relaxed and informal, with people dropping in to see each other without having to leave a card in the hall first.”
You can find more troublesome pairs here and the index to them all so far is here.