Evolution doesn't work toward a goal, and you're confusing evolution with natural selection. Evolution is the process whereby a species becomes distinct from its ancestral species. Natural selection is the process where certain traits already existing in a species are passed on to future generations because they either confer a benefit or are neutral for survival, while those traits that are deleterious for survival do not get passed on to future generations. Natural selection is simply a response to selection pressures, any selection pressures, not something with a predetermined direction, or where traits are good or bad other than in the context of the current environment. Medicine simply changes the selection pressures. Ability to fight off a certain infection is no longer an important trait because we can provide medicine for it instead.
Usually, when the selection pressure for a particular trait is decreased (same thing could happen naturally if, for example, the predator of another species went extinct...the prey species would no longer have the predation pressure to contend with), you begin to see more variability in that trait. Selection pressure usually keeps certain variations of a trait to a minimum because those variations are unfavorable (i.e., white fur color in a mouse that lives on the forest floor among brown leaves), while others become more abundant because it allows better survival in that selective environment (i.e., white fur color in a mouse living in the arctic where the ground is usually snow covered). Without that pressure, the full spectrum of variation for that trait can be expressed and passed on because there is nothing to make any of those variants undesirable (i.e., brown or white mice living in the walls of someone's house). If that pressure returns again (i.e., the house is demolished and the mice end up back in the woods), those individuals who have inherited the less desirable of the traits will wind up back at the mercy of that pressure and that trait will become less abundant again.
Keep in mind that all these terms refer to the population level, not necessarily an individual level. Occassionally, an albino mouse will survive in the woods long enough to reproduce and those genes are not completely lost, even though, in general, being a white mouse in a brown environment makes one particularly vulnerable to getting spotted and eaten by a predator.
Also, remember that natural selection does not involve acquiring new characteristics to fit a situation (they really shouldn't teach history of science...i.e., Lamarckian theory...right along with the modern day form of the theory of natural selection, it really seems to leave a lot of people thinking inheritance of acquired characteristics really happens). In other words, if you have to get food from a tall tree, you're not suddenly going to grow taller to reach the food. The population as a whole will not suddenly gain genes for tallness. If all your other food sources are gone except what's in a tall tree, one of two things happens: 1) the species goes extinct or 2) an existing trait allows some individuals to reach the food in the tall tree, and only those individuals survive to pass on their genes...for example, maybe there is a range of short to tall people, and the tallest people can reach the tree, while the shortest will all die off. There will be a shift in the average height of the population toward taller if this happens. Or, perhaps some of the shorter individuals also are really good tree-climbers even though they never needed to try it out before. Then those who are good tree climbers will pass on their genes to future generations and the species will have more good climbers. Both could also happen, the tall people and the really short, but good climbers both survive. Maybe the medium-sized people don't survive...they neither can reach the tree from the ground, nor are they small and agile enough to climb the tree. In this case, interbreeding between the tall and short populations may cease because their medium sized offspring never survive. With lack of interbreeding between the tall people and the good climbers, the populations will gradually become more distinct from on another, until they reach a point when they no longer can be considered the same species (unless, of course, prior to becoming that distinct, a food source lower to the ground reappears and they can interbreed again and produce medium height offspring able to survive).