What is this for and is it needed?

If you have a brake failure, front or rear, then that little switch/wire warns you.