If we define a robot as a machine that works like a human being, then the first robots were automata: remarkable moving dolls that could copy human actions, sometimes with amazing facility. For example, one could write a whole sentence using a pen and ink.
Automata were made in the 1700s. They worked by clockwork and contained very complex system of gears. They were made purely to astound and entertain people and could not do physical tasks like modern robots. These developed as machines became more and more automatic. However, only with the development of computers over the last 40 years have robots been able to perform complex tasks.