What would be the Elo rating of a computer which plays all optimal moves? What would be the Elo rating of a computer which plays all optimal moves?
By playing all optimal moves, I mean that it always wins if possible, or else draws if that is the best result possible.
ELO is not an absolute measurement; it is only meaningful relevant to the ELOs of other players. This is because it is only calculated based on performance against other rated players. The "Maximum ELO", which seems to be what you're looking for, is therefore equal to the ELO of a player at such a time when his ELO is so high that he cannot gain any ELO points for defeating the second-highest-rated player.

The answer to your question, then, relies on at least the following two questions:


What is the highest-rated opponent that this theoretical machine could always defeat?
How much higher than that rating does an ELO need to be, in order not to gain any points from a victory?




The problem is this: if you play this machine against itself, the outcome is undefined. If we assume (since we don't know) that Chess is a fair game (Black and White have equal winning/drawing chances), then this machine can't raise its ELO indefinitely by repeatedly playing and defeating another version of itself, because it'll lose half the time and not get anywhere. So without hacking the system (see below), there is an upper bound somewhere.

What that upper bound is, however, is very fluid and somewhat ill-defined, because players' ratings are always in motion, and because rating systems are not equivalent. So to give you a value, let me make a couple of simplifying assumptions.


"Perfect play" is always a victory. (If draws are possible with perfect play from one side, it doesn't change the endpoint, but it does make it take longer to reach the top).
We use the FIDE ELO system, including the k-factor tiers (the k-factor will be 10 in the range we care about).
FIDE only uses integer ELO values.
The highest-rated opponent for this machine is Magnus Carlsen, currently rated at 2881.
Magnus is willing and able to play against this machine as many times as needed for the machine to reach its peak ELO. Between games against the machine, Magnus will play other humans to regain his 2881 ELO rating.


Given these assumptions, the machine will max out at about 3351 ELO1, where if it wins, its ELO will increase by less than half a point (+0.49 to 3351.49), which will be discarded (rounded down to 3351).



If a competitor achieves an ELO above 2881, than the upper bound increases. This fact allows us to pull the following (very silly) stunt, if we so choose:


We have a machine that always wins.
Presumably, we could build another one.
We pit the machine against Magnus until it achieves FIDE ELO 3351.
We disable perfect play on the machine (Machine 1). We set Machine 1 to always lose.
We build another machine, Machine 2, and play it against Machine 1 until it cannot gain more ELO points.
Repeat steps 4-5 with new machines ad nauseam to create a machine with an arbitrarily-high FIDE ELO.




1 I haven't done all the calculations myself by hand. I just plugged the appropriate numbers into this calculator. It's entirely possible that the formula used there differs from the current FIDE rules, but the basic premise is the same even if the numbers are inexact.