To kick off with a potentially excessive history lesson... The start of what ultimately led to the modern classifications really kicks off with the codification of line of battle tactics during the various Anglo-Dutch Wars of the 1600s. The outcome of this was the development of two major categories, ships for the line of battle, thus, Ships of the Line, Battleships, and ships for scouting, screening, acting as a presence in secondary theaters, protecting and raiding trade, these latter ships normally had to be able to remain at sea and cruise, thus Cruiser (or using a frequent archaic spelling cruizier).
Moving through the 1600s and 1700s, in Britain this became formalized into a rating system from 6th Rate (generally carrying 20-30 carriage-mounted guns on a single gun deck) to 1st Rate (100 or more carriage-mounted guns on three gun decks). 5th and 6th Rates (often called Frigates) served mainly in the cruiser role, while 4th Rates and up formed the line of battle. And as an added complication you also had unrated ships, vessels commanded by officers of a rank below Captain... Within this category lay Sloops of War, Corvettes Brigs and various forms of gunboat, with SoWs and Corvettes often falling into the cruiser role. Large SoWs and Corvettes could often match the weaker 6th rates for firepower. As time moved on (mid-1700s to early-1800s) the line of battle concentrated onto the 3rd Rate (64 guns and up, most famously the 74s) and above, and the 4th Rate SoLs (50-60 guns) was initially relegated to station flagships for secondary theaters then (1810s and onwards) replaced with 50-gun frigates.
Then through the 1840s, 50s and 60s came steam power, shells guns, rifled guns and armour. This threw the old rating system into confusion... For instance HMS Warrior, despite being the most powerful ship afloat when launched in 1860, was labelled a frigate since she carried 40 guns on a single gun deck.
The 1860s, 70s and 80s saw rapid improvements in tech with iron giving way to steel, better engines, effective turrets, bigger guns, reliable breach loading guns, displacement of black powder with the first smokeless powders, the first QF medium caliber guns, etc. etc. etc.. Needless to say, this rapid tech advancement saw all sorts of weird, wonderful and plain batshit ideas tested out (often turning from revolutionary to obsolete before the ship left the slipway...). The names, Frigate, Sloop (of War) and Corvette generally fell out of fashion, to be replaced with Cruiser. This is also the era when Torpedo Boats crop up, first armed with spar torpedoes (a lump of bang on the end of a stick...), and later with the first "modern" self propelled torpedoes.
1880s and 1890s things settled down a bit. There was still major advancements going on but not to the same extent of rendering ideas obsolete before they touched water. Battleships stabilized on the "classic" Pre-Dreadnought design with a mixed main armourment split between heavy guns (typically 11in and grater) in two turrets with few 7-10in guns mounted in casemates, plus a secondary battery of 4-6in. Cruisers developed into three categories, unarmoured light/scout cruisers carrying 4-6in guns, protected cruisers with a low-set armoured deck covering the vitals and 4-6in guns, and armoured cruisers with a thick armoured belt and carrying an 8-10in main battery and a 4-6in secondary battery. Artillery development outran the protected cruiser and the type went out of style by 1900, replaced by "light" cruisers with a thin armored belt. Special torpedo boat destroying vessels (hence, Destroyers) were developed to screen the battle line against torpedo attack.
Then came Dreadnought and the uniform heavy main battery with guns of 11in and up mounted in 4-7 turrets with the intermediate 8-10in guns gone and the secondary armourment of 3in-6in guns specialized as an anti-torpedo-boat/destroyer weapon.. Spinning off from this you got the Battlecruiser, mostly intended to take the place of the armoured cruiser.
Then 1910s and WW1. "Fast" Battleships merging the Battleship and Battlecruiser roles started to come about, initially in the Queen Elizabeth class (though, speed fell short at 24ish knots rather than the desired 26ish knots), but didn't really come together properly until HMS Hood (and even then she was a bit weak on the armour side...). Destroyers got larger. Sloops came back but as the name for an convoy escort and minesweeper.
Then came the naval treaties of the 1920s and 30s. Battleship development was mostly frozen until 1935ish and number were heavily cut back, shifting expectations away from wars being decided by The Next Trafalgar (TM). The old armoured cruiser went bye-bye replaced with the treaty light (guns < 6.1in, displacement not exceeding 10,000 tons) and heavy (guns <8.1in, displacement not exceeding 10,000 tons) cruisers. Sloops took on an AA escort and colonial presence (see also, the Avisos of France and so on) roles in addition to ASW and minesweeping, but became a bit too bespoke for mass production.
Treaties passed away in the late 1930s and then WW2... Fast Battleships came into their own. Cheap ASW escorts were developed and named Corvettes (single screw, famously the Flower class, mostly a whale chaser redesigned for naval use, initally intended for coastal ASW but then France fell...) or Frigates (twin screw, see River class, mostly a cheaper and more mass producible sloop, intended for high seas ASW), as Sloops had become too bespoke and expensive. Destroyers (the 1949 vintage Daring class Destroyers weren't much lighter than a 1915 vintage C lass Cruiser...) and Cruisers (the extreme case being the Alaska class... exceeding the size of many WW1 Battleships) got larger.
Hitting the mid to late 1950s most Battleships and (gun) Cruisers went out of service as a combination of lack of opposite numbers; high performance all weather attack aircraft; lighter nuclear weapons; the first reliable PGMs and nuclear attack submarines made the cost vs capability equation unfavorable for "big" gun surface combatants.
Then cue a period of more naming anarchy as missiles come. The poms go for Destroyer for AA and GP combatants (Counties onwards) with Frigates being ASW escorts, Cruiser mostly disappears apart from the increasingly decrepit Tiger class and an attempt to convince Treasury that the Invicible class aren't really carriers. The US went Frigate/Destroyer Leader for their large missile armed vessels (normally fitted to act as flagships), destoyer for smaller missile armed combatants, and destroyer escorts for the ASW role corresponding to the poms' frigates... until the
1975 reclassification in response to a "cruiser gap" with the USSR. Then Frigate/DLG -> Cruiser, Destroyer -> Destroyer and Destroyer Escort -> Frigate...