I feel as if something such as "the heart evolved to beat and pump blood" or "the function of the heart is to beat and pump blood" relies on the teleological belief that organs have a "right" way to be which again relies on the belief that there is a "purpose". Without teleology, and without the belief that there is a purpose, how can there be a right way to be and how can functions and dysfunctions make sense?
The remarkable thing about natural evolution is that it is a random, unguided process that can generate complex entities that behave as if designed for a purpose.
To see how this can happen, note that evolution requires three interdependent effects to occur:
- reproduction, which creates copies of existing entities that inherit at least some traits of the original entity;
- mutation, which causes those inherited traits in new entities to (sometimes) differ slightly from those of their originals; and
- selection, which causes some of these inheritable traits to affect the survival and reproduction rate of the entities possessing them.
In general, both mutation and selection can be either "artificial", i.e. driven by an intelligent agent towards a specific purpose, or "natural", i.e. driven solely by unguided physical processes.
For example, humans have long bred dogs and other domestic animals for specific purposes by selective breeding, i.e. by choosing which animals are allowed to breed and pass on their traits, and with modern science we have also learned to manipulate the mutation part of the process via genetic engineering. Yet, on the other hand, biological mutation and selection have both been happening for billions of years even before humans showed up, with no apparent evidence of conscious intelligent guidance.
It is, of course, quite possible and even common for organisms to influence the evolution of other organisms even without conscious intent or purpose. For example, a lion that chases a herd of gazelles and picks out the slowest one to catch and eat will, through no intent of its own, end up creating a selection pressure that favors gazelles that can run fast. And some micro-organisms such as retroviruses and some parasitic bacteria can even directly manipulate the genomes of their hosts even though, again, they do so with no "purpose" other than their own survival and reproduction.
The end result of these three effects, acting together over a sufficiently long time, is a set of entities that appear to have been designed and optimized for a particular way of life, with complex traits that serve to help them survive and reproduce: a gazelle has strong legs for running, a lion has sharp claws and teeth for catching its prey, a penguin has thick body fat and feathers to protect it against the cold and flippers to swim fast, a male peacock has a flashy tail to attract females, a virus has coat proteins to help it avoid the host's immune system (which itself is a very complex evolved trait!) and enter its cells.
But none of those traits have actually been designed, as far as we know, with any goal in mind — they just happen to assist the survival and reproduction of the organisms possessing them, and thus any individuals born, purely by chance, with more effective versions of those traits have been better able to pass their versions of those traits on to their offspring.
The other side of the coin is that, in practice, it's very hard to talk about biology and evolution without using language that sounds teleological. The only alternative is to use awkward circumlocutions such as:
"humans and their ancestors have evolved under conditions where having a heart that beats and pumps blood has, on average, increased their likelihood of survival and reproduction"
"the human heart has evolved to beat and pump blood"
"humans have a heart to pump blood".
No natural human language (that I know of, at least) has convenient vocabulary and/or grammar for distinguishing between "designed for a purpose" and "evolved for a purpose" — or, if you want to be pedantic, "evolved under conditions where organisms with these particular traits or abilities have had an increased likelihood of survival and reproduction compared to those that don't, or that only have them to a lesser extent".
That said, language is also subject to evolution, and perhaps in time we will — whether intentionally or not — develop a clearer and more convenient terminological distinction between "purpose" and "evolutionary advantage". Until then, however, biologists will continue to (mis)use teleological terms to describe evolution and its results, because the alternatives are quite unfit for any kind of practical communication.
First, think of a weeble. If you push the weeble off-balance, it will return to an equilibrium state. The balanced state is an attractor for the weeble. Schematically, a simple attractor looks like this:
You see a lot of arrows pointing towards the center. This means that if the system is pushed away from the center, the arrows push it back.
It doesn't require a human interpretation to decide whether something is an attractor or not. That's just math; which way do the arrows point? And it doesn't require any inherent notion of good or bad. It just means that you have a system that, when pushed away from a certain state, tends to go back towards that state.
If a system can be divided into parts, the function of a part with respect to an attractor of the system is the role that part plays in pushing the system towards the attractor.
Animals have an attractor state called "homeostasis." Homeostasis involves a certain body temperature, a certain concentration of water and different chemicals in each of the different tissues of the body, the maintained presence of certain physical structures, and so on. If the body falls out of homeostasis, many, many biological mechanisms act to push the body back towards homeostasis.
The function of one of those mechanisms (with respect to maintaining homeostasis) is nothing more or less than the causal role it plays in returning the body to homeostasis. For example, the function of the liver is to filter out certain chemicals (that we call toxins) from the blood, and introduce new chemicals to the blood. We do not have to say this is good or bad; we don't have to say homeostasis is "good" or lack of it is "bad."
We can simply say that the fact the liver filters and introduces those specific chemicals, increases the tendency of the body to return to an attractor state (homestasis), distinguished from other states only by the fact that so many arrows "point to it."
Yes, organs have a function in an organism. And when they no longer achieve this task then organs become dysfunctional.
In order to attribute a function to an organ one needs an organism to which the organ provides a service.
A given function has not been implemented necessarily on the basis of an anterior plan. The function can also be the result of an adaptation to the enviromental conditions according to the mechanism of natural evolution. It is a basic axiom of the theory of natural evolution that the concept of teleology does not apply.
Aside: From a philosophical point of view Aristotle's doctrine of the four causes has to be restricted: Not every thing and not even every function has a final cause (= telos).
"how can there be a right way"
This is assuming that e.g. the heart is the right way to pump blood rather than just an acceptable way to pump blood. Evolution doesn't necessarily create perfect solutions to problems, just adequate solutions for the survival of the trait.
Note that humans have legs despite the fact that wheels would be a more efficient means of locomotion. Legs are however a pretty good compromise between the ease of production and efficiency.
As a further example, a lot of chemical compounds are chiral (can occur in two forms that are chemically identical but physically different via mirror symmetry). However, nature quite often only uses either the right-handed or left-handed version of the compound, but not both (homochirality). Neither is "right" - nature could have picked either chirality. So we end up with compounds that either function in our bodies or they do not, and there is no real reason for it other than chance.
The problem of defining disease is still under heated debate in the context of mental health, so it is easier to start there and generalize to physical health. The SEP gives 5 examples of formal definitions for mental illness, 3 of which avoid teleology. It is worth mentioning that they have different problems, so you have to be careful before accepting one.
A disease is the absence of [statistically] normal function of a mechanism or process in a person that detracts from the person’s survival or reproduction.
According to this definition, the proper functioning of the heart whatever the heart does in the majority of the time in the majority of individuals. This definition avoids teleology, but has to justify why deviating from the average should be considered as sign of illness.
A mental malady is a condition of a person, other than his rational beliefs and desires, such that he is suffering, or at increased risk of suffering, an evil (death, pain, disability, loss of freedom or opportunity, or loss of pleasure), in the absence of a distinct sustaining cause.
If you generalizing this definition to apply to physical disease, then a heart attack is considered a disease because it causes bad things to happen to people who have them. The proper function of an organ is essentially whatever function would bring about the best results. This view could probably work for physical diseases, it is overly broad regarding mental disease.
A condition is pathological if and only if it is an [statistically] abnormal bodily/mental condition that requires medical intervention and that harms standard members of the species in standard conditions.
This definition defines dysfunction just like the first did, as a deviation from the statistical average, so it has the same big problems. The main difference is that it changes the focus from evolutionary fitness (i.e. survival and reproduction) to "standard" situations.
These article seems to explain what you are asking about: