On his death bed, Robert Baratheon wanted to explicitly name Joffrey as his heir. Ned Stark substituted language about the rightful heir. Someone else might have written the passage as Robert intended. If Robert had explicitly said that Joffrey was his heir, then that would have greatly reduced the Stannis claim.
It has been argued that Robert's will did not matter because only Cersei read it. Even if true, Ned announced it in open court, the one place guaranteed to have active spies for all factions. Beyond that, if Cersei had had a will legitimizing Joffrey, she would have treated it differently. She'd have published it rather than destroying it. That might not have mattered to Stannis, but it would have mattered to the Tyrells and various Baratheon allies.
Without the tension between Stannis and Joffrey, there wouldn't have been room for Renly to press his claim. In particular, without Ned's claims of Joffrey's illegitimacy, Renly wouldn't have been able to run as the alternative to his brother. The Tyrells still might have preferred Renly to Stannis, but without Ned's public announcement of the illegitimacy, they would have little reason to prefer Renly to Joffrey. Much easier to marry Joffrey to Margaery.
Robert wanted Joffrey and Sansa to marry (possibly a Littlefinger suggestion). But Robert would have been dead. The Lannisters would have dumped that marriage if it gave them an advantage. We know this because that is what actually happened after Renly died. They put aside the Joffrey/Sansa engagement in favor of marrying Joffrey and Margaery. They still could have offered a Tommen/Arya betrothal or a Robb/Myrcella marriage to the Starks. The Tyrells could have sweetened that with a Loras/Sansa marriage.
Renly might have wanted to be king, but he wouldn't have been able to offer himself as a claimant without the illegitimacy. He needed the honest stamp that Ned gave it to make people seriously consider the possibility of a King Stannis. He had an in with the Tyrells through Loras, but they would likely have taken the easier path. Without Ned as Hand, it would have been far easier to negotiate a Margaery/Joffrey marriage.
Robb Stark wouldn't have been head of House Stark much less King of the North. Ned might have supported Joffrey based on Robert's expressed wishes. Note that Stannis did not try to recruit Ned. He left that to agents that stayed in King's Landing.
Ned had two ways to control the Greyjoys. First, he could threaten the hostage, Theon. Second, he had an army next door. It's noteworthy that the first place that the Greyjoys attacked was the North. Robb only had Theon, as he took the army south. If Greyjoy had rebelled, both Joffrey and Stannis would have agreed that Ned should put down that rebellion.
Balon Greyjoy simply wouldn't have rebelled under that circumstance. He needed Robb to take the entire Northern army south to make an opening. Ned wouldn't have taken the whole army south to support either Joffrey or Stannis. He'd have left behind enough soldiers to avoid an invasion from the Iron Islands. Or he'd have simply stayed put. Further, Balon rebelled after Robb did.
Robb rebelling meant that people would treat with Balon, as losing the Iron Islands would have hurt less than losing the North. No rebellious Robb, no room for Balon to split off as the small, easy to ignore splinter.
It could be argued that Stannis knew about Joffrey. But the same problem remained as when he told Jon Arryn. Stannis making that claim would have looked like it was purely self-serving. That's why he needed Jon or Ned to make the claim for him. Ned was perfect, as he had a reputation for honesty and straightforwardness. But all the proof was in the area of King's Landing. Stannis couldn't have recruited Ned in the North, because he wouldn't have been able to show proof.
If Ned had never spent time with Joffrey, he would likely have been more willing to support him. Particularly if Robert signed a proclamation transferring power to Joffrey. Inertia would have kept Joffrey in charge.
Of course, Joffrey would have still been a train wreck of a king. But without the pressure from Robb Stark in the field, Tywin Lannister could have come to the capital sooner. Joffrey would have had a regent and been less able to make bad decisions.
Stannis might still have caused problems, but he would have needed to be more cautious. And he would have still had the problem of the proof being in King's Landing while he wasn't. Plus of course, the Lannisters would have had more room to eliminate the proof (Robert's bastards). Only the genealogy records would have remained.
In order for Petyr Baelish (Littlefinger) to have gotten the war he sought, he would have needed to work things differently. He might still have done it eventually but not at the moment when Robert died. For that matter, Robert might have lasted longer, as there would have been less immediacy about killing him without Ned's investigation of Joffrey's legitimacy.