As far as I know, du is used to mention a direct object and dir is to mention an indirect object. If that is the case, why do they use "Wie geht's dir?" to ask "How are you?", when "you" is a direct object in the sentence "How are you?". Reference
Don't compare German to English. In German we're not talking about direct and indirect objects. What we concern about are cases:
The question "Wie geht es dir?" is an example of dative. And the dative form of du is dir.
In many cases you can consider the German dative case being an indirect object and the German accusative case being a direct object. This is often true; but as you've just seen, there are exceptions. Another popular one, for instance, is Ich danke dir (translation: Thank you).
Also note that the accusative object(~direct object) is dich not du as you suggested in your question.
In German, every verb can “rule” 1 or 2 objects (relative verb) or none (absolute verb). Some verbs support two or all of these variants, but often vary their meaning then. Relative verbs determine the case their objects have to be in; this is called valency. Almost all verbs require a subject, but impersonal verbs limit this to es. Objects here is used in a wider sense, because a verb may also support (or need) an adverb (or adverbial phrase), a prepositional phrase (i.e. certain prepositions which then determine the case of the nominal phrase following) or, following a copula verb, a predicative.
Most relative verbs that can (or must) rule a single accusative object are transitive verbs which can be used properly in (transient) passive voice.
Some relative verbs, mostly ones which require a single dative object, also support to reuse their subject(s) as an object with pronouns mich, dich, sich; uns, euch, sich ‘…self’. These are either reflexive verbs or reciprocal verbs. The latter require a subject that has more than one individual in its extension, i.e. plurals or groups, and are better used with the pronoun einander ‘each other’. There are also some verbs that can only be used with reflexive or reciprocal objects.
The valency of a verb determines how a sentence it appears in may be formed. Most combinations are possible:
More complex schemes usually include optional elements, and this list doesn’t claim to be complete. One could analyze things differently of course, e.g. treat PP as complex objects in the case the preposition demands (but this would result in incongruences like ich gehe mit dir and ich gehe ohne dich). Most constructs with two objects in Acc/Dat/Gen are rarely used, the second one being replaced by a PP, Adv or Inf.
Questions use the same cases as answers, i.e. statements, but usually require different word order. If any, the case is found in the interrogative pronoun(s).
To finally answer the question: the valency of gehen if used to describe a feeling is Dat+Adv and it must be used impersonally then, hence es or ’s. The interrogative pronoun wie? is used to ask for adverbials. Wie geht es dir?
Interestingly, however, the dative object is optional in a question, because it defaults to the addressee by situational context: Wie geht’s?
Don't expect every expression to be translatable word-for-word between German and English. The German expression Wie geht's dir? could be considered a shortened version of Wie geht es mit dir? (Literally, How goes it with you?)
Mit is a preposition that takes a dative complement.
The closest English translation employing the same grammatical mode is "how are things going for you?"
Just like you could not leave out the "for" in the English expression, because it is not a direct object, it is also not a direct object in German.
In "wie geht es dir", nothing happens to whoever is referred to by "dir". The person behind "dir" is thus not a semantical patiens, a person to whom something happens.