The primary reason to have the space station is to make living in space better.
The space stations of 1970s were intended to host people who worked with equipment - scientific or military, and it's still true, but with advancements in robotics the manned space stations are more adapted to people onboard.
Early spaceflights all used spaceships launched from Earth and returning to the Earth at the end of the mission. And those missions typically were relatively short - no longer than some days in many cases. It was enough to test the spaceship, to do some activities in space, like some experiments onboard, or an EVA - and within some days people can even fly to the Moon, run a short program on the surface and come back.
The last flight to the Moon, Apollo-17, took 12 days. The longest Gemini flight was almost 14 days. A long duration mission, Soyuz-9, was almost 18 days, and this is the longest flight of the solo spacecraft by today. Cosmonauts returned really exhausted from that flight. The experience suggested that for longer stays in space people need something more comfortable than a relatively tiny spaceships capable of returning to Earth.
These days, expeditions to the International Space Station routinely last for 6 months or even more. But the ISS is much bigger, it has such facilities as treadmills for exercising in space, the activities onboard are more varied - these things help keeping the body in a good shape, so it's easier to stay for a long time. Historically space stations grew in size with time, and more crew worked there at the same time, which probably adds to the variety of experiences. We do generally improve the habitability of the space stations with time, and modern stations are a long way from their precursors in 1970s.