Is it necessary, yes. Is it mandatory, no. It tells user agents the human readable language of the page so they can know to use standard alphabet. We can specify any language, naturally. So long as we are honest in the page. If a page is readable by an English speaking audience, then telling the user agent to expect German or Hindi won't make a lot of sense. It's a useful attribute if we use it correctly.
lang attribute may be used on any element and is recommended when a change in human readable language occurs in the page.
<span lang="fr">Ceci est écrit en français.</span>
Do you need to know or employ this anywhere in this course? No. Keep this for future reference and make it a habit in any work you do that faces the web.
Most linters will cough if there is no character encoding. This is a no-brainer to immediately and permanently adopt as a best practice. The character set, then the title, in that order, in every page you produce.