An author writes for 4 main reasons:
To inform (teach) –to tell about, describe, or share information about something.
Example: Math book, newspaper, non-fiction book
To influence/persuade–to encourage or convince you to think something or do something.
Example: commercial, advertisement
To express–to show; reflect thoughts or feelings.
Example: diary, journal, letter
To entertain–to tell a story, just for fun.
Example: fiction books, comics