Both of your questions about the alchemist were essentially correct.
The most common conception of the alchemist during the Middle Ages was of a scientist whose main goal was to learn how to change base metals, such as lead, into gold. More specifically, these men were trying to create what was known as the "philosopher's stone," which would then allow them to transmute base metals into gold. This was, of course, a completely futile attempt, but in the process of trying, many alchemists became knowledgeable about how different substances interacted with each other and what the properties of minerals and natural items were.
Many alchemists actually were patronized by royalty who were always looking for ways to increase their treasuries, and some patrons were genuinely interested in general scientific matters and employed alchemists because they were, in some cases, what we now call scientists--biologists, geologists, naturalists.
Although some alchemists tried to fake their success in creating the philosopher's stone or changing lead into gold and were considered to have some magical powers (until they were found out), most were ultimately judged to be frauds, but some were also respected for their knowledge of the natural world, and some became physicians, using their knowledge of chemicals and plants to attempt to cure illnesses.