Franz Ferdinand exhibited an extraordinary amount of hubris in visiting Sarajevo. The region was not happy to be part of the Austro-Hungarian Empire. He was visiting on what was a national remembrance day, honoring the previous statehood before it was subsumed into the empire. Therefore, nationalism was higher that day than usual.
The first assassination attempt, a thrown bomb, did not succeed in killing the royals, but several bystanders were critically wounded. The archduke's chauffeur carried on with the day's plans. Ferdinand would give a speech at the Sarajevo civic center and visit a hospital. If Ferdinand decided to go back to Vienna at that point his death could have been avoided.
Ferdinand went to the hospital to check on the wounded, at which point he was shot by Princip. Princip was supposed to have assisted in the bombing attempt but backed out at the last moment. He was about to kill himself out of despair when his lucky moment arrived. He took out his pistol, walked to the royal car, and shot Ferdinand and his wife Sophie, starting the events that would lead to WWI.
The tragic irony behind all of this was that assassination not in the best interest of the minority nationalist groups of Austria-Hungary. Ferdinand was far more liberal than his predecessor, Franz Josef, who had been in charge of the empire for decades. Ferdinand may have instituted constitutional reforms leading to greater autonomy for nationalist groups. Some historians even think that Austria-Hungary may have adopted a federal system had Ferdinand survived.
It is hard to say how history would have changed for the rest of Europe had the assassination not taken place. As conjecture, one can envision a more careful approach to diplomacy if Austria-Hungary had not dealt with Serbia so harshly. For decades, there had been tensions in Europe over arms races and colonial squabbles. Even Britain and France nearly went to war over colonial possessions in Africa.
In 1914, at the start of WWI, no one wanted war; trade among the European powers stood to be disrupted by a war. There would have probably been disagreements over trade and even regional wars in the Balkans, but these would not have taken on the destructive nature of WWI. Other countries would not have been involved; the conflicts would have been solved by international conferences. If there was a war it would have probably been against the Ottoman Empire to provide new colonies to Europeans and to finally give Russia the Dardanelles and Istanbul, territory it wanted for centuries. This is speculation, however, since one cannot know what would happen if the assassination had not taken place.