Let's imagine the 9 numbers written out in a list. Then the middle number is 41:
__, __, __, __, 41, __, __, __, __
To get the greatest possible mean, all of the numbers should be as large as possible, to make their sum as large as possible. 12 must be in the set, and must appear at least twice, so let's make 12 the smallest of the numbers:
12, 12, __, __, 41, __, __, __, __
The range is 75, so the largest number is 75 more than 12:
12, 12, __, __, 41, __, __, __, 87
We can now use the largest numbers possible to fill the gaps. No numbers can be repeated, because the mode must be 12 (or perhaps there are more than two 12s - this is addressed below):
12, 12, 39, 40, 41, 84, 85, 86, 87
If we used another 12 so that the mode could still be 12 even if we used the large numbers twice, we would have swapped the 39 for a 12 in order to swap the 86 for an 87 and the 40 for a 41. Clearly this will make the mean smaller, so the numbers above make the largest possible mean.