The reason why it's considered bad to expose the member variables directly by making them public is because of the concepts of encapsulation and low coupling.
If you would directly make the member variables of a class visible to the outside world, you're really showing the inside of the class to the outside world. If you need to change the implementation of the class later, and you need to change the member variables, it will be much harder to do this if the rest of your program is accessing those member variables directly - it means that your changes go through your whole program, instead of just in the class you need to change. If a variable would only be visible through getter and setter methods, you could change the class and change the getter and setter method so that the class would for the outside world still look the same (i.e. you only have to change one class).