A heading should be viewed as a title or a subtitle displayed in the document or a webpage. These are created with the <h1> to <h6> HTML tags where 1 is the largest (and most important) while 6 is the lowest level heading.
Headings serve dual purpose in the documents: they help the creators and readers interact with the content and they also affect the way search engines index the webpage.
Having a clearly defined structure with sections and subsections is beneficial for both the creator, who can convey their message better as well as for the readers, who can access the content with ease. Having a few good headings aids scanning and searching for specific information in the document as well as structuring the data contained.
Search engines use the headings to index the structure of the document and point to important keywords.