What you describe is rumination. Rumination has been demonstrated to be beneficial in resolving problems. Depressed people ruminate a lot, and I remember seeing at least one article (don't ask for a reference - I don't remember where) that claimed that this was because rumination worked as a tool to get us to focus on resolving a problem.
Rumination is an indication of focus, not of a wandering mind, even though it might superficially seem like wandering because we turn to rumination all the time whenever we have "spare cycles" and there is something important on our mind.
Meditation might also affect rumination in that it changes your mindset and a lot of the things that you previously thought was massively important and worth ruminating about start turning into inconsequential non-events to you, but that's entirely separate from reducing "wandering", and meditation won't stop you from ruminating on things you really care about (though it might train you to be more focused on when you do it and not let it cut into your relaxation, for example).
But what I at least think of as the mind wandering is the type of random chatter that leads you to go check Hackernews one second because it popped into your head that you hadn't checked it for five minutes, and leads you to grab a snack the next because you suddenly felt an urge for sugar, and have you sit and blankly dream about that vacation you'd wanted to book a few minutes later.
It well might be an accident. It might just be a byproduct of consciousness without any benefit on its own.
In fact, in most Buddhist traditions, the development of stillness (shamatha) goes hand-in-hand with the development of a widening awareness (vipashyana). Modern traditions like the mindfulness movement also seem to incorporate this tandem approach.
Personally, my wandering mind has been my greatest strength and my greatest weakness (anxiety, worry, jumping to conclusions, all or nothing thinking, etc.). I spend too much time in my head and not enough time grounding myself in reality to the point where there is serious disconnect in my awareness and mindfulness of situations (which has caused all kinds of serious grief in my life). Meditation has been recommended to me numerous times, and based on this article it looks like it's something I want to explore.