After the death of the Prophet Muhammad (peace be upon him), people were not only mourning the loss of their beloved prophet, but they were now suddenly cut off from that source of direct instructions that they felt was coming from a person who was guided by God. If they wanted to know what to do, they couldn't ask the Prophet directly. Instead, they recalled how the Prophet (peace be upon him) had acted in particular situations, and they shared that with others. Some people would act on this piece of instruction, but others might remember the Prophet differently or believe that the instruction didn’t align with what they knew of the Prophet. There were competing bits of information about what the Prophet (peace be upon him), would have said or done in a certain situation or what instructions he gave for a certain circumstance.
Political clashes within the community very early on contributed to the rise of hadith forgery. After the deaths of the Prophet, (peace be upon him), it wasn't clear to Muslims right away who should be the person that would take the reign of government after him. He was a prophet, and there could be no one to replace him in his prophetic role, but he was also a political leader. So who would take on his political role? Some championed Ali, his cousin and son-in-law. Others championed Abu Bakr, a close companion of the Prophet (peace be upon him) and the Prophet's father-in-law. Eventually the community settled on Abu Bakr, but only after some hesitation among some persons. It is said that Ali came to take the oath of allegiance to Abu Bakr after some months had passed, and Fatima, the daughter of the Prophet, (peace be upon him), had some run-ins with Abu Bakr -- they didn’t always see things in the same way.
Some people supported Ali, others Abu Bakr. They buttressed their arguments by remembering that the Prophet (peace be upon him) had said something in favor of Ali or remembering that the Prophet had said something in favor of Abu Bakr. People started to make things up, not necessarily in the earliest years, but as time progressed. Introductory books on hadith, written by Muslim scholars, explain that one of the reasons why we have forgeries in hadith is that those who supported Ali (may God be pleased with him) invented hadiths to support him. When the Sunnis heard about this, they started to invent hadiths to support Abu Bakr and counter the inventions of the others. And then when the Shiites or proto-Shiites saw what the Sunnis were doing, they increased their efforts all the more. And so you have forgeries, counter-forgeries and counter counter-forgeries.
When Ali established the caliphate, he became the fourth person in line. At the same time, Muawiya, in Syria, a relative of Uthman, the third caliph, in a way championed his own leadership. So there was a massive rift in the community leading to civil war, and naturally in that situation of civil war, people were fighting not only with swords but also with words, and what better words to fight with than words which can be attributed back to the Prophet (peace be upon him)? So some said that the Prophet (peace be upon him) had spoken in favor of one cause over the other.
But it was not only political issues that gave rise to forgery in hadiths; there were also personal concerns. It would be said that a man was having a hard time keeping his wife where he wants her to be. He thought that she should be in her place and she was asserting herself. He couldn’t tell her to obey him, because she wouldn’t listen to him. But he would circulate a saying within the community that a woman should hear and feel subdued. And he attributed that to the Prophet (peace be upon him). He would tell someone else knowing that eventually it would come back to his wife. When his wife heard it, she would obey what the Prophet (peace be upon him) purportedly said. But of course it was an invention.
These inventions were widely acknowledged by Muslim scholars who were active in carefully examining the chains of narrators. If the Prophet (peace be upon him) said something, they figured it must have been heard by other people as well. They would be asking how is it that only one person said it, and they would suspect that it was invented to support a political faction, to put women in their place, etc. It is narrated for example, that Aisha, the mother of the believers, sometimes heard men saying something and she objected. She lived close to the Prophet Muhammad (peace be upon him) for many years. She knew the kinds of things that he taught and what he stood for. When she heard what they were saying, she realized that this could not be a saying of the Prophet Muhammad (peace be upon him).
The forgeries were widespread. When Imam Al-Bukhari went about his work of trying to collect and sift the various narratives, it is reported that he started with a pool of 600,000 hadiths and out of that, he selected some 7,400, which he graded as authentic.
Now, that's not the only grade of acceptable hadith in Islamic jurisprudence; there are lesser grades. Also, in the 600,000, there were repetitions. Let me step back for a moment and explain this a little bit more. A hadith comes down to us nowadays through a chain of narrators. The Prophet (peace be upon him), said something, one of his companions heard it, that companion tells somebody else who tells somebody else who tells somebody else. That’s one chain of narrators going all the way down until it comes to be recorded many generations later by Imam Bukhari or someone else. But now suppose the Prophet (peace be upon him), told two people, who then each told two people, who then each told two people, it branches out to 2, 4, 8, 16, 32, 64. So you can have 64 different chains of narrators narrating basically the same thing that the Prophet (peace be upon him), said. So the one saying becomes 64 separates hadiths. Among the 600,000, you will have many repetitions like this – it’s basically the same saying. But nonetheless the contrast between the number that Imam Bukhari started with and the number that he included in his collection is often used to dramatize the vast difference between the pool that was available and the selection that could be relied upon.