No, it is not needed.
It is just example code.
You can delete it or modify.....
In fact endless while loop is also just typical example code, you can use any other approach.
Variable “counter” could be sometimes used for debugging purposes – for test whether task something does (however you have LED output, so it is duplicity information)….