The purpose of the Cruiser was to roam the high seas, picking off merchant vessels, troopships or stragglers of a group. So then why were heavy and light cruisers often attached to Battleship or Carrier groups, and how was their purpose different to the attached Destroyers?
You have a very limited understanding of the employment of cruisers in the time frame you are interested in. As far as I am aware guerre de course was a rather minor role for (purpose-built) cruisers in the 20th century. Their main roles appear to have been:
- Protection of trade (rather than raiding it)
- Scouting (before the dominance of aircraft)
- Acting as a fast wing of the battle line
- Screening the fleet against light forces (including aircraft)
- Gunfire support of amphibious landings
...and others that I have forgotten about.
Other than the first and last in the above list, this required the cruisers to accompany main fleet units.
The Germans did use disguised raiders and armed merchant ships of various kinds (which in a sense are technically cruisers or auxiliary cruisers) in both world wars for raiding merchant shipping, but is that really what you are thinking of?
The only instances of purpose-built cruisers used in an anti-trade role I can think of is the small number of German ships in the First World War and the early war cruises of the Panzerschiff in WW2 (I suppose some of the arctic convoy actions of WW2 might qualify).
Japan was limited to a 3:5 ratio of BBs vs the United States. In the climactic battle they expected in the western Pacific with their war plan, they would have put the heavy cruisers in with the BBs in order to try and redress the balance. IJN heavy cruisers carried heavy torpedo batteries to attack US BBs and the 6 inch cruisers allowed under the London Treaty were designed to have their guns replaced by 8 inch so that they could help fight the US battle line.
In the actual war, cruiser fire could and did inflict damage on capital ships, especially IJN Hiei.
Cruisers are built to be fast and be able to operate independently. A tin can (DD, DE) might be fast too, but they are fragile and can't carry much fuel. They often had to be topped off from Carriers or other large ships in an operation. Destroyers are also too small to have all the amenites you might need off on your own - certain equipment and medical facilities might be skimped on. A cruiser has room for these things. Destroyers are fragile - strafing can damage them to the point of sinking.
So a fleet with an attached cruiser wing could send them off scouting, or bombarding or any number of missions without risking their crews to loss to the extent a destroyer does. They are like the advanced sword while the DDs are a defensive weapon in battle and kept with the main force.
During the 1950s the main role was for shore bombardment, since cruisers had the biggest guns (battleships no longer being maintained). During the Korean War that was their most important function.
Also, my guess is that strike forces liked to have them because of their logistics strength. Cruisers are big ships with all kinds of amenities like dentist offices, chemistry labs, machine repair shops and other complex facilities that cannot be fielded on smaller vessels. This can be quite handy. For example, let's say you need to do some repair on one your ships that requires a big machine shop. If you have no cruiser, you might have to send that ship all the way back to port to get it fixed.
Most of the "pre-missile" cruisers were HEAVY cruisers that emerged as a "cross" between battlecruisers and light cruisers.
Battle cruisers represented an experiment in the design of ships with battleship caliber armament, that were faster than battleships (and presumably better for pursuit), at the sacrifice of armor protection. Admirals soon found that the lesser protection was more of a liability than the speed was an asset; in a battle against Germany's Bismarck, Britain's battle-cruiser Hood actually had the same firepower, but much less armor than the battleship, and was sunk in about 15 minutes.
On the other hand, the light cruisers had the advantage of size, firepower, and armored decks over destroyers, but were otherwise almost as vulnerable.
The result of these problems was the creation of a separate, "hybrid," class of (heavy) cruisers that were fast enough for pursuit and scouting purposes, but heavily armored enough to withstand counterattack by anything less than a battleship (which it could "outrun). And these heavy cruisers "terrorized" lighter light cruisers and destroyers that were much weaker and barely faster.