Bosnia was part of the Austrian empire,and had a sizable ethnic Serb population. Many Serbs,both in Serbia and Bosnia,wanted Bosnia to become part of Serbia.Other provinces of the Austrian empire also hda sizable ethnic minorities - Czechs,Poles,and so on - who also wanted independence from Austria.All this contributed to a lot of nationalist tension within the Austrian empire.
Franz Ferdinand was heir to the Austrian throne.He planned to introduce reforms in the empire that would give many provinces local autonomy,and allow them to choose their own local leaders. As this would have considerably reduced nationalist tension within the empire,and made it less likely that ethnic minorities would want independence of become part of other states,this was unacceptable both to Serbia and Serb nationalists in Bosnia.
The Serb Secret Police therefore recruited a number of extreme Serb nationalists from within Bosnia.They armed and trained them to assassinate the Archduke.The group was known as the Black Hand Gang,one of them being Gavrilo Princip.They took the opportunity to assassinate Franz Ferdinand when he visited Sarajevo (capital of Bosnia) on 28 June 1914.
So, Franz Ferdinand was assassinated by Bosnian Serb nationalists,backed by the Serbian Secret Police,because he planned to introduce reforms that would have made it less likely that Bosnian Serbs would want to become part of Serbia.