tl;dr – Short answer
Your example is grammatical because the reflexive pronoun has an antecedent (a noun phrase with which it is coreferential) and both are complements of the same verb. The antecedent is the indirect object (IO) and the reflexive is the direct object (DO), and in this construction reflexives are mandatory.
Long answer
Types of reflexive pronouns
Reflexive pronouns have various different functions, depending on sentence structure and what the pronoun is governed by. If you have access to it, there is a very thorough description of them in The Cambridge Grammar of the English Language by Rodney Huddleston and Geoffrey K. Pullum (pp. 1483–1499); the following is mostly excerpted from their description.
What CGEL calls basic reflexives can only be used if there is a close, structural link between the reflexive pronoun and its antecedent. The antecedent can be any kind of noun phrase (including a pronoun), and it can be covert as well than overt (i.e., it doesn’t have to actually appear as a word in the sentence) – but there must be a link between the two.1
Reflexive constructions
The two most common constructions involving basic reflexive pronouns are those where the pronoun and the antecedent are linked –
- directly through a shared relationship to the same verb (both are complements of the verb), or
- more indirectly through sentence constituents that are somehow related to the same verb.
2 includes a host of syntactically more complex cases, of which the most common is where the reflexive is the object of a preposition and the prepositional phrase as a whole is a complement of the verb (I was running from myself). But we don’t need to deal with 2 here, because your example falls under 1.
1 includes all those cases where both entities (pronoun and antecedent) are in themselves complements of the same verb. That verb can be the main verb in a sentence, or it can be in a subordinate clause. The archetypal version is where the antecedent is the subject and the reflexive is the direct object – that’s the one you’ve learnt from your teachers, and the one most online sources will give. But it’s not the whole truth; in fact, it’s only a small part of the whole truth. The fact of the matter is that it doesn’t really matter what the syntactic function of the two entities is. Here are some examples of the possible constructions where both antecedent and pronoun are complements of the verb (shown as antecedent + pronoun):
- S(ubject) + D(irect) O(bject): I injured myself, Sue injured herself
- S + I(ndirect) O: I bought myself a book, John bought himself a book
- S + P(redicative) C(omplement): I am myself, Ann is not feeling herself today
- DO + PC: I call him himself2
- IO + DO: Art shows us ourselves
As you may have noticed, the last item on that list (IO + DO) fits your example to a T.
In I showed the monkey himself in a mirror, the antecedent is the monkey, the indirect object, and the pronoun is himself, the direct object. Both are complements of the verb show, and it is this close, structural link between the two constituents which requires us to use the reflexive pronoun.
Possible non-reflexives in the same constructions
In many cases, a non-reflexive pronouns can also be used instead of a reflexive pronoun. There are two possible reasons for this: either the reflexive is optional (i.e., you can switch between the two with no difference in meaning in a given construction), or it can be overridden by a non-reflexive pronoun; in both cases, there is a tendency that non-reflexive forms are more common in the first and second persons and rarer in the third person.
As an example of the former, there are some dialects, especially in the US, where S + IO tends to be only optionally reflexive, so !I bought me a car and I bought myself a car are both possible and roughly equivalent. In the rest of the Anglosphere, the former of these is not possible (the raised exclamation mark means ‘non-standard’). In the IO + DO construction like your example, however, reflexives are mandatory.
Non-reflexive pronouns which ‘take over’ from reflexive ones are considered by CGEL to be part of the same group of override reflexives mentioned in note 1. They are called override reflexives because they can be used even where the use of reflexives is mandatory – they quite literally force-override the required form. They occur mostly in informal speech, but are not limited to specific dialects. These non-reflexives add contrast and emphasis: I injured myself is a neutral statement that I did something that resulted in an injury to my own body, whereas I injured me emphasises the contrast between my injuring myself and my injuring someone else.
Notes:
1 This is in opposition to override reflexives, which do not require any such link and can appear with no antecedent at all. Your example here contains a basic reflexive, so we can skip the override reflexives. An example of an override reflexive would be “Sarah drove John and myself to the park”, where myself has no antecedent at all and could just as well have been the regular personal pronoun me.
2 I can’t think of any reason why this construction shouldn’t be grammatical, but I will note that it is very, very infrequent. I cannot think of an example that sounds natural and likely to ever be uttered in actual speech, but I believe this is because it is exceedingly rare that we ever need to express anything where a direct object has a predicative complement which is a pronoun.