The first rule is to follow the application instructions for the specific office and role. If a cover letter is required, submit one. If it is optional, the decision becomes more about whether you have something useful to add.
A strong cover letter can help when your motivation needs context, your career path is unusual, or you want to explain why a particular office or firm makes sense. A generic letter that simply repeats the resume adds very little.
For many candidates, the resume remains the much more important document. So if the cover letter is optional and you cannot write something specific and thoughtful, skipping it may be better than submitting a weak template.
Do not treat the letter as a hidden test unless the firm tells you it is required. Use it when it strengthens the application. A useful reference is a consulting cover letter guide.