Alma 50:21 - 50:25
Alma 50: 21 And we see that these promises have been verified to the people of Nephi; for it has been their quarrelings and their contentions, yea, their murderings, and their plunderings, their idolatry, their whoredoms, and their abominations, which were among themselves, which brought upon them their wars and their destructions.
The prospering of the Nephites was evidence of the promises of the Lord being fulfilled before their eyes. It was evident that it was the contentions, the criminal activities and the immoral behavior of the Nephites that brought about the wars they had to deal with.
Alma 50: 22 And those who were faithful in keeping the commandments of the Lord were delivered at all times, whilst thousands of their wicked brethren have been consigned to bondage, or to perish by the sword, or to dwindle in unbelief, and mingle with the Lamanites.
It was the faithful and those living the gospel that were delivered from the threat of bondage and destruction. The wicked, on the other hand, were the ones who found themselves dying by the sword or who quit the Nephites and joined up with the Lamanites.
Alma 50: 23 But behold there never was a happier time among the people of Nephi, since the days of Nephi, than in the days of Moroni, yea, even at this time, in the twenty and first year of the reign of the judges.
In spite of the hard work to fortify and prepare for the Lamanite invasions, it was a happy time for the Nephites under the leadership of Moroni. In fact, there was never a time in the previous 500 or so years that the Nephites were this comfortable with their situation and happy with each other even up to the year being the 21st year of the judges.
I think it was simply the working together for a common goal under righteous leadership that was the bases for the happiness of the Nephites. There always seems to be more joy in people's lives when they know they are part of a greater thing than themselves. That is why the church is so successful. We are all working together to promote the gospel and it shows in our personal feelings of contentment and love for each other as we work together to accomplish a righteous and common goal.
Alma 50: 24 And it came to pass that the twenty and second year of the reign of the judges also ended in peace; yea, and also the twenty and third year.
The peace and lack of contention continued through to the 23rd year.
Alma 50: 25 And it came to pass that in the commencement of the twenty and fourth year of the reign of the judges, there would also have been peace among the people of Nephi had it not been for a contention which took place among them concerning the land of Lehi, and the land of Morianton, which joined upon the borders of Lehi; both of which were on the borders by the seashore.
This peace might have continued in the 24th year, but there was a dispute over the border between the lands of Lehi and Morianton which were on the seashore.