Prior to World War I Serbs managed to free themselves from Ottoman rule and establish and independent state Kingdom of Serbia. They became a first independent south Slavic nation. Croatians on the other hand were not indenependent but were part of Austria-Hungary. Austria-Hungary was on the losing side of WWI and fell apart after the war. Croatians, together with Serbs and Slovenians who lived in AH, declared independence and formed a Country of Slovenes, Croats and Serbs. This new country was not internationally recognized, and because it used to be part of AH they were technically the losers of the WWI so they were in a bad position. Kingdom of Serbia was on the winning side and after one month the Country of Slovenes, Croats and Serbs decided to join the Kingdom of Serbia and formed a new state: The Kingdom of Serbs, Croats and Slovenes which was later renamed into Kingdom of Yugoslavia.
Even prior to the reunification there were tensions between Serbs, Croats and Slovenes since they could not agree on the power sharing in the new country. Serbs wanted a centralised state in which the Serbs had the main role, Slovenes and Croats on the other hand wanted Yugoslavia to be a confederation of south Slavic states in which each state would have high degree of autonomy. This led to very tense and unstable political situation in Yugoslavia. Croatia and Slovenia were the richest parts of Yugoslavia and were angry because they were heavily taxed and had little power in new country. Serbs on the other hand were angry because Slovenes and Croats did not recognize its leading role in new country. This is what I would consider the start of the hate between both nations. The political crisis culminated in 1928 when the most popular Croatian politician Stjepan Radic was shot by a Serb radical in the Parliament.
Things got worse during the second world war. The Germans and Italians occupied Yugoslavia. They established an Indepenent State of Croatia. A puppet state that was led by Croatian fascists called Ustaše. Prior to the war they were based in Italy and assassinated the King of Yugoslavia during his visit in Marseille. Ustaše wanted to establish an ethnically pure state. To achieve that they would have to murder a significant Serbian minority that lived in Croatia. Many Serbs were murdered in Jesenovac concentration camp. You can read more about it in this post by u/commiespaceinvader
Following the WWII a new Yugoslavia was established. The second Yugoslavia was a communist dictatorship led by Josip Broz Tito. The new country inherited an old problem: Slovenes, Serbs and Croats disagreeing on how the power should be shared. This problem remained unsolved but Tito managed to keep the country together by sometimes siding with Serbs and sometimes siding with Slovenes and Croats. Immediately after the war the constitution established a heavily centralized state. The last Yugoslavian constitution in 1974 gave all republics in Yugoslavia more autonomy and weakened Serbia's role. Nobody was truly happy but Tito was a unifying figure that kept the country together.
After his death the economy went to hell and with no unifying figure old tensions came back to the surface. Slobodan Milosevic became the leader of Serbian Communist Party and was determined to increase the role of Serbia in Yugoslavia. This led to a crisis in Yugoslavia which eventually led to war between Croats and Serbs.
source: Misha Glenny, The Balkans: Nationalism, War and the Great Powers 1804-2012