It is fine and good if you are doing it with purpose (e.g. tutoring someone else in your mind to understand something better, or trying to work out some problem that has a solution), but bad if you are trying to solve something unsolvable, dwelling on the past or worrying about the future, or just wasting your own CPU cycles.
This is something you can practice as part of mindfulness practice - getting spontaneous awareness that you are engaging in an unproductive internal dialogue and letting it go. Not fight it or stop it, but just let the thoughts come and go without engaging with them.