Short answer
They were protected from major sin. Islam teaches that God (﷾) kept every prophet from major sin and from any error in passing on His message. The Qur'an tells the Prophet (ﷺ) to follow the guidance of the prophets before him, so they had to be worth following. The Bible tells a different story. It has Aaron make the golden calf. It has Lot's daughters make him drunk and conceive by him. It has David commit adultery and send the woman's husband to his death. It has Solomon turn to other gods. The Qur'an honours each of these men. It blames another man, al-Samiri, for the calf. It says plainly that Solomon did not disbelieve. Even the Bible calls Lot righteous and holds David up as a model of obedience. Islam's account is the one that holds together.
Full explanation
What Islam teaches about the prophets
Muslim scholars call this ismah (protection). Every prophet, from Adam to the Prophet Muhammad (ﷺ), was guarded by God (﷾), as a prophet, from major sin. He was also guarded from any error in delivering the message. The Qur'an tells the Prophet (ﷺ) to follow the guidance the earlier prophets received. It calls them the chosen and the good. Many scholars allow that a prophet could make a small slip, which he quickly repented of.
“Those were the (prophets) who received Allah's guidance: Copy the guidance they received; Say: "No reward for this do I ask of you: This is no less than a message for the nations."”
“And commemorate Our Servants Abraham, Isaac, and Jacob, possessors of Power and Vision. Verily We did choose them for a special (purpose)- proclaiming the Message of the Hereafter. They were, in Our sight, truly, of the company of the Elect and the Good.”
Aaron and the golden calf
Exodus has Aaron collect the gold, shape the calf, build an altar before it and announce a feast. The Qur'an tells the same event but puts the blame on al-Samiri, the man who misled the people. Aaron warned the people that they were being tested and told them to follow him. They would not. When Moses seized him, Aaron asked not to be counted among the people of sin.
“And he received them at their hand, and fashioned it with a graving tool, after he had made it a molten calf: and they said, These be thy gods, O Israel, which brought thee up out of the land of Egypt.”
“And when Aaron saw it, he built an altar before it; and Aaron made proclamation, and said, To morrow is a feast to the Lord.”
“(Allah) said: "We have tested thy people in thy absence: the Samiri has led them astray."”
“"Then he brought out (of the fire) before the (people) the image of a calf: It seemed to low: so they said: This is your god, and the god of Moses, but (Moses) has forgotten!" Could they not see that it could not return them a word (for answer), and that it had no power either to harm them or to do them good? Aaron had already, before this said to them: "O my people! ye are being tested in this: for verily your Lord is (Allah) Most Gracious; so follow me and obey my command." They had said: "We will not abandon this cult, but we will devote ourselves to it until Moses returns to us."”
“When Moses came back to his people, angry and grieved, he said: "Evil it is that ye have done in my place in my absence: did ye make haste to bring on the judgment of your Lord?" He put down the tablets, seized his brother by (the hair of) his head, and dragged him to him. Aaron said: "Son of my mother! the people did indeed reckon me as naught, and went near to slaying me! Make not the enemies rejoice over my misfortune, nor count thou me amongst the people of sin."”
Lot, drunk or righteous
Genesis ends Lot's story with his daughters making him drunk on two nights and conceiving by him. Yet the New Testament calls the same man "just Lot" and "that righteous man". The Qur'an agrees with the second picture. Lot was given judgment and knowledge, and he was one of the righteous.
“And they made their father drink wine that night: and the firstborn went in, and lay with her father; and he perceived not when she lay down, nor when she arose.”
“Thus were both the daughters of Lot with child by their father.”
“And delivered just Lot, vexed with the filthy conversation of the wicked: (For that righteous man dwelling among them, in seeing and hearing, vexed his righteous soul from day to day with their unlawful deeds;)”
“And to Lut, too, We gave Judgment and Knowledge, and We saved him from the town which practised abominations: truly they were a people given to Evil, a rebellious people. And We admitted him to Our Mercy: for he was one of the Righteous.”
David: a murderer, or a man who kept every commandment?
Second Samuel has David take another man's wife. He then orders her husband to the front line to be killed. First Kings has God (﷾) call David the servant who kept His commandments and did only what was right. A chapter later it adds "save only in the matter of Uriah the Hittite". So the Bible holds up as its model of obedience a man it charges with adultery and murder. These are two of the gravest sins in its own law. The Qur'an's David is a prophet and king to whom God (﷾) gave the Psalms, wisdom and sound judgment. It tells of no such crime.
“And David sent messengers, and took her; and she came in unto him, and he lay with her; for she was purified from her uncleanness: and she returned unto her house.”
“And he wrote in the letter, saying, Set ye Uriah in the forefront of the hottest battle, and retire ye from him, that he may be smitten, and die.”
“And rent the kingdom away from the house of David, and gave it thee: and yet thou hast not been as my servant David, who kept my commandments, and who followed me with all his heart, to do that only which was right in mine eyes;”
“Because David did that which was right in the eyes of the Lord, and turned not aside from any thing that he commanded him all the days of his life, save only in the matter of Uriah the Hittite.”
“We strengthened his kingdom, and gave him wisdom and sound judgment in speech and decision.”
“We have sent thee inspiration, as We sent it to Noah and the Messengers after him: we sent inspiration to Abraham, Isma'il, Isaac, Jacob and the Tribes, to Jesus, Job, Jonah, Aaron, and solomon, and to David We gave the Psalms.”
Solomon and Noah
First Kings says Solomon, in old age, followed other gods. Some blamed Solomon for the sorcery of the devils. The Qur'an answers them. It says it was the devils who disbelieved, not Solomon. It calls him excellent in God's (﷾) service, ever turning to Him. It never accuses him of worshipping other gods. Genesis has Noah lie drunk and uncovered in his tent. In the Qur'an, Noah leaves the Ark, his ship, with peace and blessing from God (﷾).
“For it came to pass, when Solomon was old, that his wives turned away his heart after other gods: and his heart was not perfect with the Lord his God, as was the heart of David his father. For Solomon went after Ashtoreth the goddess of the Zidonians, and after Milcom the abomination of the Ammonites. And Solomon did evil in the sight of the Lord, and went not fully after the Lord, as did David his father.”
“They followed what the evil ones gave out (falsely) against the power of Solomon: the blasphemers Were, not Solomon, but the evil ones, teaching men Magic,”
“To David We gave Solomon (for a son),- How excellent in Our service! Ever did he turn (to Us)!”
“And he drank of the wine, and was drunken; and he was uncovered within his tent.”
“The word came: "O Noah! Come down (from the Ark) with peace from Us, and blessing on thee and on some of the peoples (who will spring) from those with thee: but (there will be other) peoples to whom We shall grant their pleasures (for a time), but in the end will a grievous penalty reach them from Us."”
Why the pattern matters
Every one of these differences runs in the same direction. Where the Bible accuses a prophet of a grave sin, the Qur'an either rejects the charge or honours the man and tells no such story. The Bible itself still calls these men righteous and obedient. A book copied from the Bible would repeat these charges. The Qur'an corrects them.
“And delivered just Lot, vexed with the filthy conversation of the wicked: (For that righteous man dwelling among them, in seeing and hearing, vexed his righteous soul from day to day with their unlawful deeds;)”
“And rent the kingdom away from the house of David, and gave it thee: and yet thou hast not been as my servant David, who kept my commandments, and who followed me with all his heart, to do that only which was right in mine eyes;”
“Those were the (prophets) who received Allah's guidance: Copy the guidance they received; Say: "No reward for this do I ask of you: This is no less than a message for the nations."”
Verse by verse
2 Samuel 11:4 — Nevi'im, Shmuel Bet, chapter 11, verse 4
“And David sent messengers, and took her; and she came in unto him, and he lay with her; for she was purified from her uncleanness: and she returned unto her house.”
Cited for
The Bible's frankness about David's sin shows that it is honest, and that God forgives and uses sinners.
The response
The Bible holds David up as the model. In First Kings God (﷾) calls David the servant who kept His commandments and did only what was right. A chapter later the same book makes an exception for Uriah. A prophet chosen to carry God's (﷾) word is one people are told to follow. The Qur'an gives David wisdom and sound judgment, and tells of no such crime.
Where it lands — The Bible holds David up as the model of obedience and also charges him with adultery and murder. The Qur'an's David is a prophet people can follow.
Qur'an 38:24 — Surat Sad (The letter Saad), verse 24
“and David gathered that We had tried him: he asked forgiveness of his Lord, fell down, bowing (in prostration), and turned (to Allah in repentance).”
Cited for
The Qur'an itself says David asked forgiveness, so it also admits he sinned.
The response
The Qur'an names no sin. It says David was tested, turned to God (﷾) and was forgiven a lapse. It also says he was near to God (﷾). Ibn Kathir, a scholar of the Qur'an in the 14th century, notes that the stories told about this passage come from Israelite sources. Nothing authentic confirms them. Scholars allow a prophet a small slip, quickly repented, but never the adultery and murder of 2 Samuel 11.
Where it lands — Asking forgiveness for an unnamed lapse is not the crime the Bible describes, and it fits the Islamic teaching on the prophets.
Qur'an 28:15-16 — Surat al-Qasas (The Stories), verses 15-16
“And he entered the city at a time when its people were not watching: and he found there two men fighting,- one of his own religion, and the other, of his foes. Now the man of his own religion appealed to him against his foe, and Moses struck him with his fist and made an end of him. He said: "This is a work of Evil (Satan): for he is an enemy that manifestly misleads!" He prayed: "O my Lord! I have indeed wronged my soul! Do Thou then forgive me!" So (Allah) forgave him: for He is the Oft-Forgiving, Most Merciful.”
Cited for
The Qur'an itself has Moses kill a man and Adam disobey.
The response
Moses struck a single blow with his fist, coming to the help of a man of his people in a fight. Muslim scholars hold that he did not mean to kill. He at once asked God's (﷾) forgiveness and was forgiven. He says himself that this was before God (﷾) appointed him one of the messengers. Adam forgot the covenant, the command God (﷾) had given him, and the Qur'an calls that slip disobedience. It happened in the Garden, before he was sent down to the earth. God (﷾) turned to him and guided him. The Islamic method holds that the protection applies to prophets once they are chosen, and to their message.
Where it lands — Both lapses came before prophethood and were forgiven at once; neither is a grave sin by a prophet in his mission.
Perspectives
Christian view
Only Jesus was without sin. The Bible honestly records the sins of its heroes, and that honesty shows that God works through flawed people.
The New Testament says all have sinned, and that Jesus was tempted in all points like us, yet without sin.
Rebuttal
Islam agrees that Jesus was pure (19:19). Many scholars allow the other prophets a small slip, but God (﷾) chose them to carry His message and kept them from major sin. The Bible itself calls Lot righteous and says David kept God's (﷾) commandments.
The Bible reports that David committed adultery and arranged the death of Uriah.
Rebuttal
The Bible does report it. Yet it also holds David up as the servant who kept God's (﷾) commandments, "save only in the matter of Uriah the Hittite". So it makes a man it charges with adultery and murder its model of obedience. The Qur'an's David is given wisdom and sound judgment, with no such crime.
The Islamic perspective
God (﷾) chose the prophets to carry His message and to be followed, so He protected them from grave sin. The Qur'an, revealed to the Prophet (ﷺ), clears them of the charges the Bible makes.
The Qur'an commands following the guidance the prophets received and calls them the chosen and the good.
The Qur'an blames al-Samiri for the golden calf and records Aaron warning the people against it.
The Bible calls Lot righteous in one book and tells of his drunkenness and incest in another.
First Kings says David kept God's (﷾) commandments and did only what was right. A chapter later it makes an exception for Uriah.
The Qur'an states that Solomon did not disbelieve and calls him excellent in God's (﷾) service.
This clears him of the idolatry 1 Kings 11 charges him with.
Because every difference clears a prophet, the Qur'an's accounts are not copied from the Bible but correct it.