The bourgeoisie were the middle class during the age of feudalism. When feudalism (in western Europe) was overthrown by the working masses allied with the bourgeoisie (in the so-called bourgeois revolutions of the 18th and 19th century), the latter came to power and became the owner of capital (primary means of production under capitalism). In some places where aristocracy was stripped of political power, it was left with enormous privileges (mostly in the form of land, from which they acquire rent).
Similar to how a feudal or a capitalist state reflects the necessity of preservation of interests for the ruling class (aristocracy->bourgeoisie), a worker’s revolution needs to overthrow the existing oppressive structures in order to establish a worker’s state, where the interests of the proletariat (the vast majority of the population) would become dominant. Classes would still exist in such a society, long after the initial unrest. This is called socialism. Its aim is to keep the previous ruling class suppressed long enough until sufficiently accumulated economic, political and cultural achievements would provide a chance for the society to further develop into communism, a society without classes.
In such a society, (socialist) states would wither away on their own, because there wouldn’t be any class confrontation anymore. Therefore, there would cease to exist the need for the workers to defend themselves from capitalist restoration.
Just as the capitalist (bourgeois) uses the capitalist state to defend himself and his interests (wealth, power) from the proletariat, so the workers need to use the socialist state to defend their newly acquired gains. This, of course, takes a lot more time than was given to the perpetually besieged socialist states of the 20th century.