Question : What is Term Frequency ?
Answer : Term Frequency refers to the frequency of each term.

Question : What is IDF ?
Answer :   Well with term frequency, in a document, there will be a lot of frequency for words such as a, the. And if we compare the two documents based on this frequency only, then it will yield a poor result, because all the documents  have a, the words with large frequency. What IDF does is does not give more weights to such commonly occurring words.

Question: Interesting. But how does Term Frequency – Inverse Document Frequency (tf-idf) work?
Answer: Term frequency captures the number of terms in a document i.e f(t,d). Hence it is able to capture the importance of words in a document. However, where it fails is with commonly occurring words in the language such as a, an , the. So how do we capture them. A brute force way is to create a dictionary of such commonly occurring words or capture a dictionary with word frequency score, based on its commonality manually annotated and use it. However the dictionary will not be adaptive enough to respond to changes in language and will require human labor, which might not be accurate enough.
A more better statistical approach will be to look at how many document have the word vs the total number of documents. This is called Inverse document Frequency.
idf = idf(t,D)