The South Slavs settled in the area between the Adriatic and Black Seas in the 7th century AD. In the 19th century, these ethnic groups started developing into nations. A language is often an important quality of a nation, so the politicians started influencing the languages the people spoke. The story about Serbo-Croatian is one of the most interesting stories about the South Slavic languages.
Prior to the 19th century, in the areas today known as Croatia, Bosnia and Herzegovina, Serbia and Montenegro, the people were speaking in the following different dialects:
- kajkavian ("kajkavski", named after the fact the word for "what" is "kaj"), spoken in the northern and western areas of Croatia; somewhat similar to Slovenian, with many elements picked up from German due to the Austrian rule
- štokavian ("štokavski", named after the fact the word for "what" is "što"), spoken in eastern and southernmost parts of Croatia, and most of Bosnia, Serbia, and Montenegro; had been influenced by German due to the aforementioned Austrian rule, and by Turkish due to the Ottoman rule
- čakavian ("čakavski", named after the fact the word for "what" is "ča"), spoken along most the Adriatic coast in Croatia; influenced by Italian due to Venetian rule
- torlak ("torlački", the origin of whose name is unclear), spoken in southern and eastern parts of Serbia. This one sticks out because it is often referred to as a transitional phase between štokavian and Macedonian, and even thought to fit into the so-called Balkan Sprachbund, an area of linguistic convergence among languages due to long-term contact rather than being related. This convergence also includes Albanian, Aromanian, Greek, Romanian, Romany, and, to some extent, Turkish.
Make no mistake, the word used for "what" wasn't the only difference between the first three dialects, it's merely used in the naming scheme -- they had many differences in grammar, spelling and vocabulary.
In addition to the above dialects, there was another differentiation in the speech, based on how the old Slavic "jot" sound was pronounced:
- ikavian ("ikavski"), e.g. child=dite, wind=vitar
- ijekavian/jekavian ("ijekavski/jekavski"), e.g. child=dijete, wind=vjetar
- ekavian ("ekavski"), e.g. child=dete, wind=vetar
Ikavian is commonly paired with cakavian and stokavian, ijekavian most commonly with stokavian, and ekavian with both kajkavian and stokavian in some places.
Anyway, back to the history. You must have noticed how the names of the above terms don't have anything national in them, despite the fact these peoples have had their own nation-like kingdoms ever since the Great Migration. This variety makes it hard to have a standard national language, so the national movements that came to existance in the 19th century tried to change it.
A panslavic movement was started in Croatia by some of the younger intellectuals at the time, obviously aimed at uniting all the Slavic peoples into one nation. This was too utopian and they realized it themselves, so they switched to a smaller subset: just the South Slavs. Their new Illyrian movement supported unification among the Slovenes, Croats and Serbs under the Illyrian name. They chose that name becase they believed that these nations were descendents of the Illyrians. This was quite a stretch, since the Slav tribes overwhelmed the native Illyrians back in the seventh century when they immigrated.
Vuk Stefanović Karadžić was a Serbian linguist which came up with modern spelling rules for the Serbian Cyrillic alphabet in 1818. He travelled through Serbia, Montenegro, Bosnia and Herzegovina and Croatia, writing down the stories the local people would tell him and later analyzing them to find the common components upon which he would build a proposal for a standard language.
Ljudevit Gaj was one of the leaders of the Illyrian movement, and he seemed to have very much liked Vuk Karadžić's standardization ideas. In 1830, he finished his own spelling rules for the Croatian Latin alphabet. He took the diacritical graphemes mostly from Czech, and made the alphabet analogous to the Serbian one.
On the 28th of March 1850, a group of eight met in Vienna to sign the so-called "književni dogovor", literary agreement. Among them there were five Croats: Dimitrije Demeter, Ivan Kukuljević Sakcinski, Ivan Mažuranić, Vinko Pacel, Stjepan Pejaković, two Serbs: Đura Daničić and Vuk Karadžić, and finally one Slovenian, Fran Mikložič, who officially hosted the event, sponsored by the Monarchy in an attempt to ease communication among the Slavs in its southern regions.
Given the political situation at the time when these people lived, it was impossible for their more radical ideas about South Slav unity to come true, despite the fact their ideas about the language were starting to get grass roots support (although they did receive a fair amount of opposition, from equally prominent writers and linguists such as Adolf Veber Tkalčević or Fran Kurelac). But in the 20th century, after the First World War, the South Slavs came under one government, that of the Serbian Karađorđević dynasty, and the Serbian language became official. This language used the ekavian speech and the stokavian dialect, and Cyrillic script.
The Kingdom of Yugoslavia, which is how the Karađorđević-ruled country was called, fell apart in the Second World War, and many non-Serbs didn't like the overall Serbian domination, in language like in everything else. After the war, a socialist Yugoslavia was formed and the nations once again lived together, but the language situation was redefined.
In 1954, the leading linguists which supported the idea of the unified standard language signed the so-called Novi Sad Agreement about the Croatian or Serbian Literary Language (Novosadski dogovor o hrvatskom ili srpskom književnom jeziku). The signers seemed to be mostly Serbs, and the first person to sign it was an important Bosnian novelist Ivo Andrić, a 1961 Nobel laureate in literature (for his work "The Bridge on the Drina" or "Na Drini ćuprija", 1945).
The standard Serbo-Croatian or Croato-Serbian language was based on the dialect spoken in eastern Herzegovina and western Montenegro area, which was geographically in the center of the country (kind of like Toscana in Italy, where the Italian standard language originated).
However, the language wasn't quite unified: it had two variants, "Serbo-Croatian" or "srpskohrvatski" and "Croato-Serbian" or "hrvatskosrpski". The former variant, used predominantly in Serbia, was basically the Serbian language, and the latter variant, used predominantly in Croatia, was what we today call the Croatian language.
As noted above, Serbian used/uses "ekavian" speech and "stokavian" dialect. It is written in the Cyrillic script. Also, it is quite common to integrate foreign words in Serbian.
Standard Croatian used/uses "ijekavian/jekavian" speech and "stokavian" dialect, and is written in the Latin script.
The "ikavian" speech and the "kajkavian" and "cakavian" dialects are still widely accepted as official subdialects but not really standard.
Conversely, it is quite common to coin neologisms for foreign words in Croatian.
An important document aiding the dissolution of Serbo-Croatian was the 1967 Declaration about the Name and Position of the Croatian Literary Language (Deklaracija o nazivu i položaju hrvatskog književnog jezika).
The declaration asked for the right of the Croats to call their language by their own national name (i.e. Croatian) and to enable its unimpeded development, and expressed a protest against the Serbian predominance in official texts in Croatia. It was signed by numerous leading Croatian writers and linguists, including Miroslav Krleža, novelist and playwright, a dominant figure in modern Croatian literature and a longtime director of the Lexicographic Institute in Zagreb.
Many of those were later persecuted and maltreated by the Yugoslav police, by the way. In general, socialist Yugoslavia had a tendency to try to supress anything national, fearing it would grow into nationalistic. However, repressive measures backfired in the whole situation and some people actually started trying to speak as differently as possible from the prescribed norm.
With the demise of Yugoslavia, Croatia declared Croatian its official language, Bosnia and Herzegovina uses Bosnian, Serbian and Croatian, and Serbia and Montenegro are using Serbian.
The Montenegrin language hasn't been officially instated, at least not yet. They relate to the Serbs considering culture and history, however, their speech is not ekavian, it's ijekavian, and even more ijekavian than the one used by the Croats. Some proposals for the standard Montenegrin include three more letters in their alphabet, too (e.g. letter s with an acute, as a softer counterpart to the one with the haček which is already used).
While the three "new" standard languages are all still very similar (being based on štokavian), they are separated and they have started diverging.
The notion of a central South Slavic diasystem is still often used in local dialectology to cover all of the "old" dialects, although some also represent each of stokavian, Croatian and Serbian as a diasystem.
The essence of the matter is that sociolinguistically, the Serbo-Croatian language as such is de jure and de facto becoming a thing of the past. The various nuances aren't nearly as linguistically important as is the symbolic value that is assigned to them by their ethnically, religiously, socially and politically diverse group of speakers.
Note also that the other South Slavic nations have "kept" their national languages: Slovenians speak Slovenian (Slovene), Macedonians speak Macedonian and Bulgarians speak Bulgarian. All of these, even though they are related and similar to Serbian/Croatian/Bosnian, differ from it in grammar, spelling and vocabulary.
P.S. I disagree with what TAFKAH wrote above: the differences between Croatian and Serbian sure seem to be larger than those between US and UK English. Please don't insist on how the difference is so minute that it's not worth mentioning, since the difference was obviously large enough to get numerous Croats harassed over the past decades for speaking the way they speak.