Vinay92 gave a good explanation here https://forum.duolingo.com/comment/33480818 of how (to someone)+(infinitive)+(hai) expresses "have to".
Basically, you always use ko when saying "must" or "have to". Sometimes, it's built into the pronoun your using, so you might not notice it. But for example मुझे is a contraction of मुझको, which is "to me".
I remember to use "ko" by thinking of the infinitive as representing a duty that "falls to" someone. "आमिर को मेरे घर आना है।" --> "the duty of coming to my home falls TO Aamir." It's a bit of a distortion, but at least it keeps me remembering to use "to".
Edit: to be clear, even though the way I remember to use 'ko' makes it sound like "the duty of ..." is the subject, it is not. The subject of the sentence is still "Aamir". Another reference from Vinay92: https://forum.duolingo.com/comment/29214093.
Someday, maybe. Just maybe. I'll get my brain around the fact that sometimes the subject is in the oblique case (which in English makes it feel like an indirect object) and remains the subject, even though the verb agrees with something else in the sentence. Sigh. :-)
In Hindi the cases are marked by postpositions. को is the dative/accusative marker. It means that the only function of को is to mark the direct object of the sentence. However, in Hindi when dative/accusative case is used with the Infinitive participle, the dative marker actually marks the subject of the sentence and not the object.
Note, here in the given Duolingo sentence, को is used in its dative sense. It's a very common structure in Hindi.
- Noun/Pronoun (in dative) + Infinitive Participle + Copula (होना) [conjugated].
The Infinitive participle always uses the pronoun/noun in the dative case. Such sentences are equivalent to "have to" or "want to" of English. Both are equally valid translations. It is the Infinitive participle and not the Infinitive because the Infinitive marker ना here changes depending on the gender and the number of the object of the sentence. For example, किताब (book) is feminine singular, किताबें (books) is feminine plural, काम (work) is masculine singular and plural. So,
- आमिर को किताब लिखनी है। (Aamir wants/has to write a book)
- आमिर को किताबें लिखनीं हैं। (Aamir wants/has to write books) (nasalisation is optional for लिखनी)
- आमिर को काम करना है। (Aamir wants/has to (do) work)
- आमिर को काम करने हैं। (Aamir wants/has to (do) works)
In English "work" is both singular and plural but I wrote "works" just to show it's in plural.
Also note that the noun/pronoun in the dative case is actually the subject of the sentence and not the object.
Some verbs, like आना have an implied "को", so since he must "come to" the home, home is in the oblique case. घर doesn't change because its singular oblique form is the same as its singular direct form.
You'll sometimes hear an implied postpostion (in this case "को") referred to as a "ghostposition".
because there is already an implied postposition. You can choose to use it. Using a postposition there is not wrong. So, the sentence is actually like that below:
- आमिर को मेरे घर (में/को) आना है।
But, remember if you choose to use the postposition here the meaning conveyed (or better said the nuance conveyed) would often be very different and that is why Duolingo probably will not accept any postposition there.
Often with motion verbs like आना, जाना etc postposition is implied. But only for certain generic nouns such as "one's home", "a country", "a city", "a zoo". And very specific non-generic nouns such as "a union" will always have a postposition after them. So, roughly, using the oblique case there marks whether it's a generic thing or a very specific thing you're talking about.
आमिर को मेरे घर आना है। - Aamir has/wants to come to my home.
आमिर को मेरे घर में आना है। - Aamir has/wants to come in my house.
आमिर को मेरे यूनियन में आना है। - Aamir has/wants to come to my union. (you cannot skip the postposition here).
You should report it next time you run into it. I think your answer should be accepted.
FYI, घर and मकान are only approximately interchangeable. घर has connotations of the place you call "home", and can be used for broad statements like "India is my home" -> "भारत मेरा घर है" as well as referring to exactly where you live. मकान refers to the structure. "I live in a house" -> "मैं एक मकान में रहता हूँ".
Arguably Duo could claim he's trying to stress the difference between घर and मकान. But between you and me, I think they just missed this one when they coded for potential correct answers. :-)