I heard that Sweden was poor during the 19th century before implementing economic reforms which would ultimately allow them to implement socialism
This is a hard question to answer, but I will try anyway.
In general, Sweden was never poor. It was sparsely populated, and lacked some concentration of wealth that allowed other countries to construct prestige buildings a such as palaces, castles and cathedrals. Estimations put the GDP per capita never being under 20% lower than the richest parts of Europe in history.
Sweden had a substantial middle class in its self-owning peasants who never owned less than 30-40% of the arable soil in Sweden and were represented at the Estates Parliament. However, below these peasants and their families a permanent lower class of landless agricultural labourers started to rise as population rose back from the Black Death in the 14th century. Before the late 16th century, being landless was more of an age thing than a social thing. You worked as a farm hand or a farm maid to save up for the time you married and started your own farm, either as a crofter or as a slash-burner farmer in the forest.
Sweden started pretty early on land reform and if not mechanisation, then at least "ironisation" of agriculture. The closure of the commons, distribution of common and state land and shift of land from communally owned plots (as land could be split in inheritance, it was not uncommon to own small strips of a field, necessetating communal farmin) to modern style farms with single-held plots gathered together, surrounding a farmstead.
At the same time, increases in iron production and agricultural production allowed more and more peasants to invest in iron tools - plows, spades, shovels, harrows, treshing machines etc. made from iron, allowing men to be much more effective made a surplus population on the countryside and fierce competition for whatever agricultural labour there was to be had. Thus arose the class of statare, families who would sign on at larger farms or estates as labour for a year, getting paid in a fixed amount of agricultural produce and housing, the latter which would be in extremely deplorable state. The conditions for statare could be similar to those of continental serfs, and many ended up in debt to their employers due to lack of cash pay, forcing them to accept even more deplorable conditions as they could not move away due to the debt once their year was up and they could seek other employment.
This system, and the plight of the people in it, and their inability to improve their situation regardess how much they wanted to or how hard they worked due to the lack of a cash pay to save up was the source of much debate and was written about in books and newspapers, which might colour the perception of this era, as the so called statarskolan of authors, among them the prominent Ivar-Lo Johansson(himself the son of a statare) wrote realistically and candidly about the plight of this class and made sure large amoutns were printed cheaply so that the people he wrote about could afford to read about themselves.
The increasing population (the population doubled between 1750 and 1850), the decreasing need for labour on the countryside and Sweden's later entrance into the industrial revolution meant that there were hard times for the lower classes - the cities and industry could not yet swallow the excess people from the countryside, and the result was a large-scale immigration to America. Betwen 1850 and 1920, roughly 1,5 million people emigrated to the USA - and in 1850 the population had been around 3 million!
This also conceded with several bad harvests and a famine 1867-69 that struck especially hard against the poorer people who had broken new agricultural land in marginal areas, especially in northern Sweden.
At the same time, Swedish industry, mostly based around forest products and the traditional strong iron industry started to enter the industrial revolution in earnest, and the state invested heavily in railroads and other infrastructure, with Nils Ericsson (older brother of John Ericsson of the USS Monitor fame) leading and actively arguing first for canal construction and then railroad construction, including a base network between all the larger towns and cities of Sweden for private companies and industrial railroads to attach to.
Meanwhile, the public school reform of 1842 had increased the general knowledge of the population, and a generation of inventors and engineers arose during the late 19th century, including Johan Petter Johansson (the adjustable wrench), Gustav Dalén (the AGA gas lighthouse) and Sven Wingquist (the moder ball bearing) durign the Swedish part of the industrial revolution.
Was Sweden economically unstable during the 19th century? Yes, there was a surplus of labour due to agricultural reform and increased availability of iron tools and emigration was the simple answer. But Sweden had that in common with most of Europe barring perhaps Britain, Belgium and France and was ahead in the fact that a lot of land was in the hands of a stbale middle class of self-owning peasants who invested in their farms and tools for their work, creating a stable base for the Swedish traditional iron industry, which probably helped propel Sweden into the industrial revolution, despite a severe lack of coal.
Sweden built a strong industry during the late 19th and early 20th century, and together with stable democratic reforms, a strong civil service relatively free of corruption, a relatively meriocratic goverment and the luck/sense to stay out of both ww1 and ww2 left Sweden in an excellent position to capitalise on the post-ww2 boom era, and much of the current Swedish wealth is based on that.
That said, Sweden is not a socialist country, perhaps it is best described as a capitalist country with a relatively generous tax-funder welfare program, which today is not that different from most of the western world, despite its reputation.
Edit: I feel really silly having to put my own name in a link or the automoderator will message me and tell me I should name the link.