The fate of the believers in the city of Ammonihah may be a lesson for all who believe. People ask, "Why do bad things happen to good people?" Books have been written in attempts to answer this question.
In this instance in the Book of Mormon, the good people who had the faith to believe the message of hope taught by Alma and Amulek were rounded up and burned alive. Amulek wanted to intervene and stop the carnage through the power of God. But Alma answered him in this way:
11 But Alma said unto him: The Spirit constraineth me that I must not stretch forth mine hand; for behold the Lord receiveth them up unto himself, in glory; and he doth suffer that they may do this thing, or that the people may do this thing unto them, according to the hardness of their hearts, that the judgments which he shall exercise upon them in his wrath may be just; and the blood of the innocent shall stand as a witness against them, yea, and cry mightily against them at the last day.
God can't immediately reward all good and punish all evil without affecting our agency. Freedom to choose is his most immutable law. A hymn written by an anonymous author and included in the first LDS hymnbook in 1835 is called "Know This, That Every Soul is Free."
1. Know this, that ev’ry soul is free
To choose his life and what he’ll be;
For this eternal truth is giv’n:
That God will force no man to heav’n.
2. He’ll call, persuade, direct aright,
And bless with wisdom, love, and light,
In nameless ways be good and kind,
But never force the human mind.
3. Freedom and reason make us men;
Take these away, what are we then?
Mere animals, and just as well
The beasts may think of heav’n or hell.
4. May we no more our pow’rs abuse,
But ways of truth and goodness choose;
Our God is pleased when we improve
His grace and seek his perfect love.