The Book of Mormon: Chapter Twenty-Six: Alma 13:4-5
4And thus they have been called to this holy calling on account of their faith, while others would reject the Spirit of God on account of the hardness of their hearts and blindness of their minds, while, if it had not been for this they might have had as great privilege as their brethren.
5Or in fine, in the first place they were on the same standing with their brethren; thus this holy calling being prepared from the foundation of the world for such as would not harden their hearts, being in and through the atonement of the Only Begotten Son, who was prepared—
Agency is the often overlooked building block in the Lord’s plan for our happiness, and while much evil and hardship is endured as a result of this necessary gift and catalyst for our growth, its effects are the ultimate eternal lives of those who follow Christ, as indicated clearly below by an LDS (“Mormon”) apostle.
God gave his children their free agency even in the spirit world, by which the individual spirits had the privilege, just as men have here, of choosing the good and rejecting the evil, or partaking of the evil to suffer the consequences of their sins. Because of this, some even there were more faithful than others in keeping the commandments of the Lord. Some were of greater intelligence than others, as we find it here, and were honored accordingly. . . .
(Joseph Fielding Smith, Doctrines of Salvation, 1:58–59).