In his talk "The Evolution of Confusion", Dan Dennett asks an import question: What is the function of of theology? And his answer is basically: To explain the unexplainable, mainly to the priests, to get rid of nagging questions.
Now, one can ask the same about psychology, what is its function? Well, nominally it is the "Science of the Psyche", the study of the human mind, how it works, why it is the way it is, and if it doesn't work as it could*, then to ask what are the pathological changes and its causes, and to investigate what could be done to alleviate those problems. And as such, it is a legitimate field of science, and a legitimate field of medicine. Especially evolutionary psychology is producing some very interesting scientific results IMHO (cf. "The Robot's Rebellion", Keith E. Stanovich).
However, there are some problems with the science in psychology: Considerable stuff in psychology is still pre-scientific claims, idealistic BS, unscrutinized common sense (because "everybody knows that!"), unrefuted faulty science, confirmation biases of the researchers and many ad-hoc just-so stories with unverifiable and unfalsifiable narratives.
And that leads me to one of the main problems with psychology, one of the social functions of psychology (and a scientifically, medically and humanistically quite undesirable function at that): Psychology produces narratives, for general practitioners and for the public. Narratives, that seemingly explain medical and social problems that seem to be otherwise unexplainable:
" … because, you see, that person is mentally not well … "
And such a verdict, spoken with scientific authority, ends any discussion of other factors. It shuts down any questions whether the perceived mental illness might actually be something else, whether it really is all "just in the mind" of the person. And if it is an illness that objectively manifests itself with mental symptoms, it stops most inquiry into non-psychological factors. If there are other factors, factors that should be considered as the actual cause, the psychological narrative is very effective in closing down these avenues of inquiry.
How convenient, for those confronted with the seemingly "mental ill", if they can come up with a simple answer – and not have to tackle more complex problems that reality throws at them. The patient is the problem, case closed, next patient please. And the psychologist delivers a seemingly scientific rationale why a doctor should not devote his resources to an seemingly "unhelpable" case.** And if the patient lacks insight (and possibly rightfully so) into his mental illness, this becomes a self-fulfilling prophecy.***
Now I wrote above "psychology seemingly explains" because in my view in many areas it simply plays into "common knowledge" and does not actually explain anything in a social, medical, biologic and evolutionary context. And I write "problems that seem to be otherwise unexplainable", because if one takes time and a critical approach, I am convinced one will find in many cases other explanations, more plausible explanations (albeit more complex explanations, in most cases), for many things that are seemingly explained by psychology.
* Defining how the psyche should work, or what "normal" behaviour is, that is already very difficult – In whose interest should we define how the psyche should work: The individual's interests? The society's interest? The interests of psychologists? Or some self selected upholders of moral standards? And if we define disease as pathologic ill function in the environment of evolutionary selection (because a fish out of water is not diseased), that raises the question in the face of changes in our social environment: What is normal function in a substantially changed environment anyway?
** During our evolutionary past, this might have been an advantage for the group. Help those that need little help, and can be easily and fast helped ("acute" conditions that pass) – abandon those that you can't help ("chronic" conditions). Such a behavior today would rightfully branded as "social darwinism" – our evolutionary past has left its mark on our behavior, I'm afraid.
*** And anyway, if certain social conditions don't make you angry and mad, there is something wrong with you. Plenty of examples to go around, so feel free to pick one that makes you angry and mad.