I think the best way to figure out "why" a construction has to be a certain way
is to see how it got to be that way, or whether it is usual or not for a language to do things this way. There are three issues:
- How does a verb meaning "to possess" develop a meaning where it expresses obligation
- Why does the following verb of the embedded clause appear in the infinitive?
- Why is que rather than de or something else used as a subordinator?
As for (1), Heine & Kuteva (2002: 333) name seven frequent grammaticalization sources for the concept of OBLIGATION. These are COPULA, DO, GET, NEED, OWE, H-POSSESSIVE, SUITABLE.
(An H-possessive is "a marker of predicative possession expressed, for example, in English by have". (ibid.: 163)). So let's take it on their authority that it is frequent cross-linguistically for have-like verbs to end up expressing obligation. The fact that ter is, or is related to, a verb helps us to explain why this particular construction has to involved two linked clauses: a matrix clause containing the verb ter, and an embedded clause describing the obliged action.
On a side note, use of Latin habere does actually show up in this sense. (See towards the bottom of the CNRTL entry for avoir). The quote from Varro that is cited is "rogas ut id mihi habeam curare"
So, why is an infinitive used in the embedded clause? Here we can note that cross-linguistically, constructions involving two linked clauses often have a pivot-controller relation (see Van Valin 2005: ch.4) holding between arguments of the two clauses. An argument of one clause which is expressed (the "controller") is understood to be coreferential with an unexpressed argument (the "pivot") of another clause. Since the person who is obliged to do an action is normally the one who is doing the action, it makes sense for this construction to have a pivot--controller relation where the subject of the matrix clause will be the same as the subject of the embedded clause. The relevant property of the infinitive is that it is not marked for its subject; this is fine since it is unnecessary to indicate the subject. (I don't speak Portuguese, but I am guessing that you couldn't use one of the personal infinitives in place of the regular infinitive in this construction)
Why que instead of some other subordinator? My partial guess is that because the construction probably developed from one with similar meaning, but where ter has an object, e.g. "Tenho trabalho que fazer", it will just take the subordinator from that construction. Note that in French, for example, which has a similar construction avoir à + INF, the relevant form with an object for avoir uses à to introduce the infinitive: "j'ai ce travaille à faire".
Heine, B.; Kuteva, T. (2002). World Lexicon of Grammaticalization. CUP [please do not illegally consult the copy posted on scribd.com by some unscrupulous person]
Van Valin, R. (2005). Exploring the syntax-semantics interface. CUP.