They were part of the same political entity to begin with, the Austrian-Hungarian Empire. The Czech part belonged to the Austrian part of the double monarchy, the Slovak part to the Hungarian part. They were, to put it mildly, oppressed pretty badly culturally and politically by the Austrians and Hungarians. So, they strived for independence.
I actually think it was Woodrow Wilson who cooked up the idea of putting them in one and the state when the Monarchy fell apart after WWI. They were part of the Cordon Sanitaire, so Czechoslovakia's very purpose (from a French and British pov) was to stop Lenin's ideas from spreading around. The country was then called Czechoslovak Republic. It was, at least in context of history, quite a prosperous, liberal, multi-ethical state. Some historians even refer to it as the "Switzerland of the East". During WWII the Czech part was de-facto under German rule, while Slovakia was a Nazi-German puppet state. They only got under Soviet influence after WWII.
The issue was, the Czech part was more advanced, had a lot of industry that was built up in the monarchy, while the Slovak part, aside from maybe Bratislava and Kosice was rather rural prior to the communist period. Ergo the Czech part was richer. In the end they split up in 1992 because the respective political elites from both parts of the country weren't able to get along.
Anyway, that's the history lesson for today, kids

.