Speed is probably the most important stat in Pokemon. As certain answers already pointed out, having a high Speed stat allows a Pokemon to go first, but this is applicable in a lot of different scenarios. The most obvious are KOing an opposing Pokemon before they have a chance to move and ensuring that the opposing Pokemon isn't able to outspeed and KO you. These applications are common with offensive Pokemon, as they usually have high offenses, low defenses, and often are in the KO-or-be-KOed game. However, defensive Pokemon can have a use for Speed too.
For example, in the early days of Gen 9 OU, Scream Tail, with its high base Speed outspeeding the benchmark of base 100 Speed, uses its unique combination of high bulk and speed to spread Thunder Waves everywhere, supporting its team. A fast Scream Tail can probably pull off a Thunder Wave against any Pokemon it outspeeds, even if it is at low HP. In contrast, a slower paralysis spreader, like Nuzzle Hatterene, may struggle to get off another paralysis before being KOed if it is at low help. Speed helping these "utility" mons can appear in other situations too. Iron Treads, a relatively fast Rapid Spinner, can clear hazards one last time before fainting. This is a small advantage it has over Great Tusk, who is slower and cannot do the same at low HP if against a faster Pokemon, like max Speed Landorus-T.
TLDR: A more defensive/utility focused Pokemon can also utilize Speed if it uses the Speed to spread its utility, such as spreading status conditions, setting up screens or hazards, or removing hazards.