Not sure how much help I'll be (since I was never hired for any of the jobs I applied for that I actually used a cover letter) but, here is what I remember being told:
Don't just write a generalized letter. Modify the letter for each application sent out. You want to appear you are looking for a job
with them specifically not just in general.
If you know specifically who the resume is going to, address them by name.
It doesn't need to reiterate everything in the resume, but it does need to explain why you are qualified for the position.
Explain why you are a good fit for the company - not just for the job.
It's a good place to list other experiences that could be useful but aren't in the formal resume.
There are several sites that have pretty good guides - I used several back in the day (sadly, those bookmarks appear to have been lost - I checked).
Though after a cursory search, these seem pretty decent:
https://resumegenius.com/how-to-write-a-cover-letter
https://zety.com/blog/how-to-write-a-cover-letter
Finally, I saw this a few days ago - It's actually not a bad way to break it down:
Luke Skywalker's Cover Letter