The original manuscript reads “rightfully belonged unto them”. Oliver Cowdery accidentally replaced rightfully with rightly when he copied the text from 𝓞 into 𝓟. This change is in agreement with two instances of “rightly belong” in the original text (one of which occurs in the very next verse after Alma 54:17):
Here in Alma 54:17, the original text has a unique reading that has been eliminated from the subsequent text—although, to be fair, there are only two opposing instances of “rightly belong”. In fact, these three cases are the only instances of the words rightly and rightfully in the entire Book of Mormon text. Since rightfully is clearly the reading in 𝓞 and it does work, the critical text will restore it.
There is one additional textual variant here in Alma 54:17, namely, the replacement of the preposition unto with to in the 1953 RLDS edition, thus changing “belonged unto them” to “belonged to them”. In fact, the two instances of “doth rightly belong” (listed above) have the preposition to rather than unto: “to whom the kingdom doth rightly belong” (in Mosiah 29:6) and “to whom the government doth rightly belong” (in Alma 54:18). But more generally, the Book of Mormon text allows variation between the prepositions unto and to. See, for instance, the discussion regarding the phrase “to give heed (un)to X” in Alma 21:23. The critical text will retain the original preposition unto here in Alma 54:17.
Summary: Restore in Alma 54:17 the adverb rightfully, the reading in 𝓞 (“when it rightfully belonged unto them”); also maintain the original preposition unto in this clause.