What role does the pronoun play in the sentence? If it's a subject, it should be in the subjective case. If it's an object, it should be in the objective case.
As I parse this sentence, "him" is the object of the preposition "but". The prepositional phrase "but him" modifies the pronoun "nobody". The nominative phrase "nobody but him" is the subject of the clause. "Was" is the verb. "Present" is a predicate adjective.
However, there is an alternate view. The word "but" can also be a conjunction. As a conjunction, it would join the subject "nobody" with the subject "he". As a subject, "he" takes the subjective case.
Since both options are grammatically possible, which should we prefer?
I could say that, in my dialect, the first sounds more natural. That may be true, but it isn't very helpful.
There is a version of this sentence such that "but" must be a preposition: "Nobody was present but him." To my ear, this version means the same thing as the original. For that reason, I recommend treating this instance of "but" as a preposition, and treating "him" as the object of a preposition.
In general, English does not have much of a gender system. We divide things into male people, female people, and everything else.
Men and boys use the masculine pronouns he, him, his.
Women and girls use the feminine pronouns she, her, hers.
Everything else uses the neuter pronouns it, it, its.
But there are a few odd parts to how we use English in practice. Animals are often called he or she if we know their gender and it matters to us. For example, our pets are very personal to us, so we usually call them by masculine or feminine pronouns, not neuter ones. Animals that aren't so "personal", we usually call by neuter pronouns even if we know the sex - for example, you might say, "There's a cow in my front yard. Why is it there?" even though we know that a cow is female.
Ships are traditionally called "she", but this is seen as increasingly old-fashioned. Sometimes this is extended to other objects if they seem to have a personality, mostly vehicles, but it's rare.
There are a few nouns in English that are specifically gendered - actress, waitress, editrix, chairwoman, and so forth - but we seem to be moving away from using these words in favor of neutral forms like waiter and editor. In the case of words like chairman/chairwoman, there's still an argument over whether a female person holding the office of chairman should be called chairwoman, chairman, chairperson, or just chair.
Best Answer
Child is gender neutral. As a result, when referring to a child, one must then choose a pronoun he,she or they when referring to the said child, as English does not have a gender neutral way of referring to that individual. This causes a problem for writers. Whatever you choose could be wrong.
Some would write he, but that sounds sexist and presumptive. Some write they, but this does not confirm the singular as it could refer to many. As an alternative some writers have taken to using she to balance those that historically have used the masculine form.
Other writers go to great lengths to avoid any of these forms by just rewriting the sentences completely.
Stack Exchange questions and answers have the same problem. Do we refer to a writer as he, she, they...? Whatever one chooses makes implications that it may not be correct.
We almost never use it or its to refer to a child, as this form is reserved for objects and not people and thus is considered to be demeaning.