We have two ways to express necessity and obligation in Spanish: tener que + infinitive and hay que + infinitive.
Look this examples:
Homer Simpson tiene que ponerse a dieta.
Homer Simpson has to go on a diet.
Hay que comer más frutas y verduras diariamente.
One must eat more fruit and vegetables daily.
Both mean almost the same. They are used to say that “someone has to do something” or “something has to be done” but there is an important nuance to take into account in order to choose one form or the other:
Is one way to express obligation or necessity. This expression can be translated as “someone has to do something.” Tener is conjugated according to the subject of the sentence.
Is used to express the idea of “one must do something” or, “it is necessary to do something.” The obligation is not addressed to anybody in particular but to people in general. In fact, the verb “hay” doesn’t change form, is impersonal, since it doesn’t have any subject to accord to.
Here you have some examples to see the differences in use:
Hay que beber al menos dos litros de agua cada día.
At least two litres of water have to be drunk every day.
He empezado a hacer una dieta y el médico me ha dicho que tengo que beber mucha agua.
I started to go on a diet and the doctor told me to drink a lot of water.
Finally, if you want to practice your listening skills, here I leave you with a video class about this topic in Spanish with subtitles in Spanish.