These words (adverbs) overlap in meaning: both describe actions which are right, or correct, in either a moral or logical sense, usually moral.
The difference is that rightfully refers to people’s rights (human rights, legal rights, etc.) and other matters of justice, or what is appropriate—while rightly applies more generally to matter of correctness:
Rightfully/*rightly, she does not have to answer any police questions. (by her legal rights)
Paula added the numbers rightly/*rightfully and got the correct result. (correctly)
Julie rightly/*rightfully returned the money that she found on the ground. (morally correct)
In other words, rightfully means “with the (legal) right” while rightfully means “in a correct manner.”