A cover letter is a 1-2 page tailored document where you can share additional context with an employer (such as why you're interested in that specific job/company), or elaborate on details about your background and skills beyond what is in your resume.
Do I need a cover letter?
Cover letters are rarely required for software developer jobs. Many tech industry and software developer opportunities do not ask for cover letters. If you are transitioning from another industry, this may be a change for you.
If you are applying at a company that's not purely tech or software (for example, a developer role inside another type of business, such as a nonprofit or insurance company, etc), then you are more likely to be asked for a cover letter. Smaller companies are also somewhat likelier to accept cover letters.
Sometimes, apprenticeship programs will ask for essays, short responses, or statement of interest. They will usually ask you to respond to a specific prompt or describe your fit for the program.
What if a job posting asks for an optional cover letter?
You can choose whether or not to include a cover letter. Optional cover letters are treated differently by each employer. While some do read submitted cover letters as part of application review, others may only refer to the cover letter later in the process, such as if you talk about your cover letter in an interview or when evaluating candidates.
Reflection questions to help you choose:
Do they ask for a cover letter at all? If not, you can probably skip it. One recruiter may be very excited you have included a cover letter with your resume even if it was not asked for. Another person might think that it's a sign you are submitting the same generic cover letter to all companies, or that you did not read instructions.
Do you have time? Cover letters can take anywhere from 30 minutes to 1+ day to write and tailor to a specific employer or job posting. It's better to apply to jobs when they are "fresh," ie. the more recent they've been posted, the better. If you are competing against a deadline or want to be an earlier applicant, then you might not want to delay your application by writing a letter.
Do you care about this employer? If you particularly care about an employer or role, you might decide to put in the extra effort to write a cover letter and give context about your passion or unique skill fit.
Cover Letter Guide/"Template"
Technical Interview Prep with Ian Douglas: Cover Letters - Relevance & Layout
CV Compiler: Do you need a cover letter for a tech job? Here’s what data shows
The Muse: Your Complete Guide to Writing a Cover Letter