What is the point of a cover letter in journal submission? Many journals do specify that cover letters are optional. From my experience, most people write cover letters in journal submission, but I am also aware that articles can also be published without the cover letter. Therein arises the question: why are cover letters written if they are not necessary for the publication process?  My guess is that perhaps it helps to prevent the desk-reject from the editor.
Prior to online submission forms, cover letters let the authors communicate information to the editors. Information I have included in covers includes:


Why the manuscript fits into the journal (if i recall correctly, Ecological Indicators explicitly requires a statement of what "indictor" you are addressing in the manuscript)
Potential reviewers and blocked reviewers
A statement that the manuscript is not under review elsewhere 
Other pertinent information for the editor such as why the manuscript is timely (for example, perhaps you are studying a species that is under consideration for listing as an endangered species, and the information may be public, but not widely known)
Responses to reviewer comments
How I am meeting the journal's open data/open code requirements 


With current online journal submissions, all of this information can be captured in online forms. Hence some journals either no longer require cover letters or outright do not allow authors to upload them. Conversely, I have seen other journals that still require cover letters.

I suspect journals use of cover letters depend upon the history of the journal, their current online publishing system, and the culture of the editorial team and office.