Happily means in a cheerful way, or fortunately. Playing happily, happily married, happily nobody was hurt.
The second sense comments on the whole sentence rather than on the verb — happily, the rain stopped — and it is the older of the two, since happy first meant lucky. Happily ever after ends the fairy tale. Note hap, an old word for chance.
1adverbhappilyIn a cheerful way.
“The baby was babbling happily to herself in her cot.”
2adverbfortunatelyFortunately.
“The car was badly damaged but, happily, nobody was hurt.”
Too few real examples of this word to estimate which sense is commonest.
happily is a manner, or a comment.
Happy plus -ly. Happy first meant lucky, from hap, chance, which is why happily can mean fortunately.
Middle English
happily
English, today
happily
From Middle English happily, happyly, happyliche, happylyche, equivalent to happy + ly.
Etymology from Wiktionary, CC BY-SA