بسم الله الرحمن الرحيم
"We appointed thirty nights for Moses, then added ten more: the term set by his Lord was completed in forty nights. Moses said to his brother Aaron, 'Take my place among my people: act rightly and do not follow the way of those who spread corruption.'" (Surah Al A'raf: 142)
Musa (as) left the Banu Isra'il to meet Allah at an appointed time on Mount Tur. During his absence he left his brother Haroon (as), also a prophet, in charge to keep the people on the right path. In the absence of Musa (as) Banu Isra'il constructed a calf (from the ornaments they they had taken from the people of Firawn) as an idol to worship. Despite the warnings and protestations of Haroon (as) who spoke out against such shirk Banu Isra'il persevered in such disobedience, committing the most hated of sins. Allah says in the Quran:
"In his absence, Moses' people took to worshipping a mere shape that made sounds like a cow- a calf made from their jewellery. Could they not see that it did not speak to them or guide them in any way? Yet they took it for worship: they were evildoers". (Surah Al A'raf: 148)
While Musa (as) met with Allah he received guidance to share with Banu Isra'il. Given tablets containing Allah's commandments, Musa (as) was then informed by Allah that his people had gone astray in his absence. Distressed and grieved Musa (as) rushed back to Banu Isra'il. On seeing them worshipping the calf with his own eyes, such was his shock that he dropped the tablets given to him by Allah. After condemning their shirk in the strongest terms Musa (as) burnt their idol and threw it's ashes in the sea.
Realising they had gone astray Banu Isra'il wanted to repent to Allah, but for their repentance to be accepted those amongst them who had not worshipped the false idol were required to kill those who had as the heaviest repentance for the worst of sins. Having brought themselves to this awful juncture Banu Isra'il were forced to pay the ultimate price for incurring Allah's anger and punishment.