These words are a special part of speech known as the article. It helps us differentiate which one of the things that we are talking about.
You use the when you are talking about a noun that is very specific. If you say “the school”, you have a particular school in mind.
It could be the middle school that you attended when you were in 7th grade, with a specific name and something that applies to only that school. You would not be talking about any other school. This helps the listener or reader know what you are talking about, especially when you use a common noun.
When you say “a book”, you are not talking about any single book in particular. It could be any book that you see, from a large dictionary to a picture book.
If your teacher says, “Please bring a book to class,” you could bring any book that you see and that is convenient for you to have. Even if it is in another language, it would still fulfill your teacher’s request.
An is just a special form for a. Because it would be difficult and confusing to say two vowels at once (a apple, for example), an is used to replace a when the next word starts with a vowel sound.
Note that this is not always the same as a word that simply has a vowel at the beginning of the word – the vowel has to also sound like a vowel. Take the word unicorn.
The letter u is a vowel, but the first syllable of the word is pronounced like you, with a y consonant sound, not with an uh, or short u vowel sound. For that reason, we would say a unicorn, not an unicorn.