Harut and Marut were angels sent to Babylon to teach magic to humans and test their faith in ALLAH SWT, however, they would not teach magic to anyone until they had informed them of the nature of their work and warned them about it. Most of the people continued practicing and earning sorcery, thus falling for the bait of temptation.
The two angels, Harut and Marut are mentioned in the Quran in surah baqarah.
Allah Swt states in the Quran: “They followed what the Shayatin gave out (falsely of the magic) in the lifetime of Sulaiman. Sulaiman did not disbelieve, but the Shayatin disbelieved, teaching men magic and such things that came down at Babylon to the two angels, Harut and Marut, but neither of these two (angels) taught anyone (such things) till they had said, “We are only for trial, so disbelieve not (by learning this magic from us).” And from these (angels) people learn that by which they cause separation between man and his wife, but they could not thus harm anyone except by Allah’s Leave.” (Quran 2: 102-103)
According to the tafsirs of Ali ibn, Ibrahim and Ayyashi narrated from Imam Muhammad al-Baqir that angels were startled by the disobedience of humankind on earth. On seeing their misdeeds, the angles became astonished by the sins committed by humans like disobeying ALLAH SWT and making false allegations against HIM. So, a group of angels said to ALLAH SWT: O Lord! Even though You have prohibited them to disobey you, they are committing sins day and night. Lord! You tolerate them even though all of them are in Your control and are living a life of ease due to Your bounties. So ALLAH SWT willed to show to the angels what is His perfect Power and how He issues His commandments in the world of His creation, and to make the angels aware of His blessings as they have been created sinless and He has made them distinct among His creations and has made them ever obedient and has not given them the power of sinning.
To their response, ALLAH SWT asked them to select two angles from among them who will be sent down to the earth with the nature of human beings and with all the desires of humans inherited in them.
The angles chose the two Angels Harut and Marut. ALLAH SWT sent them to Babylon in the form of two graceful men inheriting in them all the attributes of human beings and ALLAH SWT warned them to avoid the sins like drinking alcohol, idolatry, fornication, and,killing.
When Harut and Marut came down to earth, they came across a very beautiful woman. They were mesmerized by seeing the beauty of this woman. The woman realized that Harut and Marut were not ordinary men so she invited them to her place and offered delicious food followed by her graceful dance. The angles got tempted and fell into the trap of shaitan and asked her to sleep with them. The woman refused their offer saying that her religion does not allow her to sleep with someone with a different religion.
Temptations overpowered HArut and Marut and they agreed to commit shirk and consumed wine on her demand. They were ready to commit fornication when suddenly a beggar arrived at the place.
Harut and Marut asked him: Who are you and why have you come here? He said, “Your condition makes me doubt your intention. You are fearful and frightened and yet you have brought this woman to seclusion. Surely you are evil fellows.” Saying this he went away.
Then the woman told the angles, “I swear by my god that this man knows you and is now aware of your intentions and will surely disgrace us. So I will not come near to you until you kill him so that. By this time the two angels Harut and Maruthad already committed the major sins and were completely captivated by the beauty of this woman and were ready to do anything she said. So they ran after that man and killed him. In the form of humans, they could not control their temptations and committed all the sins that were forbidden by ALLAH SWT.
According to some narrations, it is said that the Angels Harut and Marut were hung upside down in the air and will remain like that until the Day of the Resurrection Day. as a punishment by ALLAH SWT, and the women who came to know about the secret of the two Angels disappeared from the surface of the Earth. It is said that ALLAH SWT transformed her into a planet named Venus.
There are various narrations and stories available declared by different scholars related to Harut and Marut however there is no authentic hadith that can be traced down to Prophet Muhammad SAW. The details mentioned in the Holy Quran about Harut and Marut do not relate to this story as well. And ALLAH knows best.