Type 5 is a Mind type, Type 4 is Heart type. Mind types predominately deal with Fear, while Heart types predominately deal with Sadness and Shame.
… primarily deals with the fear of being invaded, intruded upon. Type 5 is typically the most withdrawn type in the Enneagram (especially when they are Sp/Sx, not as much when they are Social first). They withdraw as a way to cope with their fear of not being able to deal with the outside world. They accumulate knowledge and try to acquire an expert position, because they believe that will help them with encountering and handling the outside world. However, this coping behaviour commonly isolates them, because there is seemingly no end to the preparation they have to do before they feel “ready” to face the world.
… primarily deals with their sadness over “what is missing”, all the flaws in their life and relationships, and/or being unloveable for what they deem to be an intrinsic flaw of character (that they usually cannot put a finger on – because it is not actually “real”, but due to their personality structure they believe so; negative experiences amplify this impression). These perceived flaws makes them feel ashamed or dissatisfied (Social 4s feel the most of that self-shame, Social last 4s the least). Type 4s see their flaw as being shameful, but also the thing that makes them unique. As a coping mechanism, average 4s will exaggerate their unique traits, as a way to cover up their flaw(s) and be seen as a person worthy of love. Or in other words, average Type 4s equate being unique with being lovable, or having a unique lifestyle or unique contributions as mire valuable.
Another way to look at 5 vs 4, is by recognizing the fact that Heart types are also Image types. All Types 4 are concerned with their image: their outward appearance and how other people receive it, and/or their own sense of personal identity. In a way, they believe that one’s image or sense of self can determine whether one is being loved or not. Type 5s don’t think that way at all, they usually care little about their image, often times they (deliberately or not) cloth themselves poorly, because they care so little. They also don’t see how their image or sense of self makes people either love or hate them. Type 5 focuses mainly on their intellectual capacities, that is where their pride but also fears lie. As the Type 4 believes their image (usually of being a unique individual) brings them love and admiration, the Type 5 believes it is their intellectual know-how and brain power that will bring them the respect of others and a sense of security.
When it comes to their emotional/psychological state, Type 4s typically suffer from mood swings and/or a melancholic attitude at average to unhealthy levels, while Type 5s are typically in a state of detachment or ambivalence from many to most outside events, being a mere observer of life at average to unhealthy levels.
Generally speaking, which of the two main issues, fears and compensatory mechanisms is more dominant in you is likely the type you are. To put it in perspective, the wing type is an add-on to your personality, but the main type’s issues are always more complex and difficult for oneself. Ironically, many people are more aware and accepting of their wing type’s issues at first, because the main type’s issues are so deeply ingrained in one’s sense of self that they can be somewhat unconscious and ultimately more hurtful to oneself.
As a side note, your MBTI type gives you a hint at which of the two types you are, most likely. If you are INTP or INTJ, you are probably 5w4. If you are INFP, INFJ of ISFP, you are probably 4w5. More about MBTI-Enneagram correlations here. Click on the respective type for examples of 5w4 vs 4w5 individuals.