This is the reason why the author wrote a text. Authors can have more than one purpose (and usually do!). Sometimes, a text can have more than one purpose at the same time.
For the 4 major types, think "PIEE"
Persuade - written to convince the reader to do something or think a certain way.
Inform - written to describe something, give information on a topic or event. Not especially exciting or amusing.
Entertain - written to amuse the reader, to have fun
Express - written to show strong emotions or feelings.