I read a lot of stories as a kid that were set in earlier centuries, and often poor children would be described as wearing rags. I pictured it then as them wearing old, tattered clothes with tears and stains. I think this interpretation came from the stories often being set during winter, so when they were described as shivering in the cold, I would imagine them being so cold because their clothes were full of holes. Was being "dressed in rags" actually more like wearing patchwork clothing, or maybe wearing older clothes that had been mended beyond recognition?
A little of both - clothing that was patched/mended, and clothing that was heavily damaged.
My frame of reference here is 18th and 19th century London, so don't take this as a universal answer, although some things will apply to other early-modern/industrial era cities.
It's only in recent decades that clothing has become extremely cheap, due to a combination of synthetic fabrics, a system of low-wage factory production and global container-ship distribution. The £5 made-in-Bangladesh t-shirt you can buy in a shopping mall is an anomaly, historically speaking.
Textiles were expensive to produce - silk, for example, was handwoven on looms, and workers paid by the piece. Until the mechanisation of the textile industry, in the 19th century, fabric was the most expensive factor in determining the price of a garment. That said, while labour was cheap, and tailors/seamstresses paid a pittance for their work, the sheer amount of work that went into hand-sewing, say, a court dress, added to the production cost of the garment. As an example, the fabric alone for this 1750s mantua, in the collection of the NMS, is estimated to have cost the equivalent of £5000 today.
[Edited to add: the care and upkeep of clothing was likewise laborious and relatively expensive, and it's not until the mid-19th century that public washhouses are developed, enabling people without the means to hire a laundrymaid or washerwoman to clean their clothes easily]
As a result, there was a thriving market in second-hand clothing. As Beverley Lemire has written, used clothing was a far commoner mode of consumption for most 'ordinary' working people. In London, the centre of the new textile trade was also a key location for the sale of used clothing - Spitalfields, where the English silk-weaving industry was based in the 18th and early 19th centuries, was also home to an important second-hand market, which expanded in the 1880s.
[Edited to add: even relatively wealthy people considered the expense of textiles when purchasing or making clothing - there are a number of museum examples of garments made from fabrics that predate their shape by as long as a century, such as this example in the Met]
Of course, the working classes of 18th/19th century London were not homogenous. There were many working families who earned a regular liveable wage, dressed 'respectably' if not fashionably, and might have a 'Sunday best' outfit in addition to weekday working clothes. We're really dealing with the absolute poorest; people without regular employment, the sick, disabled or addicted, who struggled to keep a roof over their heads and food on the table. For a sense of what 'dressing in rags' might have meant for people like this, take a look at the so-called 'Spitalfields Nippers', photographed c.1900-1910 by Horace Warner. Most of these children are barefoot, many have holes in their garments. Some are wearing things that have clearly been passed down or bought second-hand, e.g. adult-sized jackets, which might have been fine when new. Even so, many of the children have made an effort with the resources available to them - girls with curlers in their hair, and boys with jaunty hats.
For more detail, I highly recommend 'Clothing the Poor in Nineteenth Century England' by Vivienne Richmond; also 'The Dress of the People' by John Styles.