The detent spring keeps the detent arm pressed into the detent wheel (more like a star), which keeps the shift drum from turning unless something moves the shift lever.
So it keeps the bike in whatever gear it is in.
The hydraulic thing is an alternative to the clutch cable. Either of them pull the clutch pressure plate off the clutch pack, when the lever is pulled at the handlebar, disconnecting the engine from the transmission