The word comes from the Czech robota, a word literally meaning forced labor, but which is also used figuratively to mean drudgery, hard work. Robota has cognates in several Slavic languages, and the use of robot in English to refer to the system of serfdom in Eastern Europe dates to the early nineteenth century.
But the sense meaning an artificial being that can, in some fashion, take the place of a human is more recent. This sense of robot was coined in 1920 by Czech writer Karel Čapek (1890–1938) in his play R. U. R. (which stands for Rossum’s Universal Robots).
While this is all technically true, it leaves the misleading impression that Čapek simply repurposed the existing word robota. He actually created a new word, robot (feminine form robotka), on the basis of that preexisting word.
The word android, an automaton that resembles a human, dates to the eighteenth century.
Actually, it dates to at latest 1657; see this LH post.