Less harm is better than more harm. It's also impossible to walk around without ever stepping on insects, but just because some harm is inevitable that doesn't mean I should walk around and slaughter everything that I can find.
With a vegan diet (ideally also vegan clothes, cosmetics etc.) you achieve a significant reduction of harm to the planet, animals and also humanity itself (climate warming, pandemics, working conditions etc.).
That doesn't mean that veganism is 'perfect' in all aspects. Who knows - maybe in the future we'll find ways to produce healthy and delicious food straight out of air and electricity without any involvement of living organisms and thereby further reduce harm. But for the moment doing what we can would be a huge step forward.