The definite article the is the most often used English word, see here. However, even though it only has three letters, its pronunciation can be tricky. There are three different pronunciations, the so-called weak forms [ðə] and [ði], and the strong form [ði:]. You can listen to all three forms here.
The is most often pronounced as [ðə]. In particular, the “th” is pronounced as in words such as this, that, or though, but neither as [θ] (as in think or through) nor as [s] (as in say or so). The latter, incorrect pronunciation is quite common among German native speakers, and seems to be tolerated even in school. One explanation for the aversion of German speakers to the [ð] and [θ] sounds is that they are often associated with a speech disorder (lisping).
The weak form [ði] is typically (but not always, see below) used when the precedes a word that has a vowel sound at the beginning. For example,
the importance of being earnest,
the idiosyncrasies of the English language
Similar to the case of a vs an, it is the pronunciation rather than the spelling which determines the pronunciation of the, a fact which is very often overlooked. For example, the is usually pronounced as [ðə] in
the unicorn is a rare animal
the uniform’s purpose is uniformity
For more examples, see here.
The strong form [ði:] is used to emphasize the subject that follows, such as
‘the’ is the most often used English word
I had lunch at the best restaurant
In practise, you will notice that neither native nor non-native speakers always follow these principles. For example, many non-native speakers pronounce all occurrences of the in the same way, typically either as [ðə] or as [ði].
Although the “[ði] before a vowel sound, [ðə] else” rule is usually taught to learners of English as a second language, I have been told that (1) this rule is in fact not a rule, but rather a guide that leads to pronunciation that mimics that of native speakers, (2) most native speakers are unaware of this “rule”.
The Longman Pronunciation Dictionary has the following to say:
“The EFL learner is advised to use [ðə] before a consonant sound (the boy, the house), [ði] before a vowel sound (the egg, the hour). Native speakers, however, sometimes ignore this distribution, in particular by using [ðə] before a vowel […], or by using [ði:] in any environment, though especially before a hesitation pause. Furthermore, some speakers use stressed [ðə] as a strong form, rather than the usual [ði:].”
A good example for a deviation from the rule is the song “Love and the Marriage” by Frank Sinatra. Listen and wait for the phrase “the other”…
Interestingly, in most other recorded versions of this song, “the” in “the other” is pronounced as [ði].
From discussions with native speakers (see here), I have learned that while the distinction between a and an is a strict grammatical rule (and deviations from this rule will be noticed as a mistake), the pronunciation of the is not determined by strict rules but depends on context, dialect, etc.