Pushing the sofa against the wall is what most of us do first, because it is the easy answer. But a sofa that floats, with its back a little way into the room, can make a living room feel more like a place to sit together and less like a corridor with furniture around the edge. Whether it works comes down to one number: how much room is left behind it.
A sofa on the wall faces the room but belongs to the wall. A sofa with a gap behind it draws a soft line through the space: this side is for sitting, that side is for walking, storing or working. In an open-plan room or a long, narrow one, that line is the cheapest "wall" you can add, and you can undo it in two minutes.
The price is floor area. Every centimetre you pull the sofa out is a centimetre taken from somewhere else, so in a small room the answer is often "leave it on the wall". That is a perfectly good answer, and it costs nothing.
These are rules of thumb, not laws, and design writers quote slightly different ranges.
Also keep the sofa and any fabric clear of radiators and heaters. Heat dries out upholstery and is a fire risk if something sits right against it.
Float it when the room is open-plan, when a sofa on the wall leaves a dead empty middle, or when you want a reading nook, desk or dining corner behind it. Floating also helps when the only wall long enough for the sofa has a radiator, a window or a door on it.
Leave it on the wall when the room is under about three metres across, when the passage behind would eat most of your floor, or when you rent and the layout is already tight. A sofa that sits close to the wall and a rug that holds the seating together is a calm, free arrangement.
Moving a sofa costs nothing, so you do not need to buy anything to find out. If you later want a slim console or shelf behind it, measure its depth against the gap you chose and check the height against the back of the sofa.