Assalamu Alaikum. In the verse (2:54) what was the moral behind it? Why was it better for them to kill each other?
Alaikumassalam wa rahmatullah,
That was part of a long series of judgments (covered in detail in the Bible) on the Israelites for their rebelliousness and disbelief. They would promise to be good believers, then quickly forget their promise and start sinning and worshiping things other than God, so God would send a plague or some other harsh judgment on them that would obliterate the rebels among them so that only the faithful would remain. Then many of them would again rebel and God would again destroy the rebels so only the faithful would remain. Part of God’s goal in this was to turn them into an example for all of humanity, showing us how God deals with those who rebel against Him. As for 2:54 specifically, this time rather than God Himself destroying the rebels, He commanded the faithful followers of Moses to execute all those who had worshiped the calf.
I know that sounds harsh but it was justified in their case. God saved them from Pharaoh, provided them with miraculous food from the skies, miraculously shaded them from the sun, protected them and defeated their enemies for them and constantly showed them other miracles. Yet instead of showing thankfulness, many among them casually turned their backs on God and rebelled when they felt like it, even while Moses was among them. This continued after Moses as well–they constantly killed prophets, worshiped Baal and allied themselves with pagans for their own gain, ignoring their religious duties.