What is the purpose of it? The only thing that comes to mind is stabilising the fork so it does not wobble to the sides so much. Is that its purpose? Why do some bikes have it?
The purpose of such a steering damper is to stop the front wheel from turning when using a (two-leg) kickstand or while pushing the bike. Not much use otherwise.
It's steering damper. It prevents your handlebar from self - turning. Increase comfort. Steering damper
I'm going to guess that the bike's fork is lacking in follow (ie it has straight forks, or forks without enough bend) so that without the spring, the bike will not self-center. It will likely feel that it wanders over the road and the rider has to actively keep it centered. You probably can't ride hands-free without the spring.
The spring provides some pull back towards the center position. If its your bike, try disconnecting the spring and going for a short ride. Does it feel different in steering and front-wheel braking?
Personally I've never seen a bike with such a spring. If they're not uncommon in your area then there may be a regional influence on them. Is it mostly step-through frames that have this? Is it budget/BSO bikes?
EDIT: Thanks Moz - Trail is the word I meant. Here's my idea. Your bike looks like a sit-up bike rather than a racer, so its an older shape/design. As per this image, older bikes had little trail, so to get them going straight you had to hold the bars all the time, which is tiring. Riding this hands-free would be a challenge.
So by comparison here's a more modern bike geometry, that will self center a lot easier. Riding hands free on this would be easy.
I think the spring reproduces some of the trail that would otherwise be absent.