The story
Originally slang that first appeared in the mid-19th century with a (usually pejorative) reference to the difficulty of leaving a well-worn rut (see in a rut). As back in the groove, the phrase acquired a positive sense of returning to one's usual self after a period of illness, setbacks, etc. With special regard for music, originally US jazz slang from the 1920s, possibly with reference to the grooves of early records.
Etymology from Wiktionary, CC BY-SA 4.0.