Well, the psychology explanation for this is quite easy. And knowing the exact reason why you miss someone who has hurt you can and will help you to hear better. With that being said let's jump right into it.
The ultimate fundamental reason why we miss someone or something is that once it made us feel good. Our brain functions in a very different way then we might assume. Its job is to keep you safe and happy at this particular moment. That is all it does.
And now you may think how is it helping me by reminding me of the very person who screwed me over! isn't it the very thing that is causing me pain! And for this, I will have to tell you that your brain does not know the freaking difference. If you were in a relationship for a long time, (or even if you was short and you were very much attached to that person) then the chances are, every time when you were alone, sad, felt hurt, were happy, you shared it with that person and they listened to you or supported you that made you feel good. You know, our brain releases a hormone call Dopamine that makes us feel good, which is highly addictive ( it is the same hormone that is released when people smoke, drink and do drugs).
And now when they have left you, have hurt you, chances are you are feeling lonely, afraid, empty, sad. Now guess what your brain is trying to do to make you feel good. Admonishing you of the person who was the reason for that sweet sweet dopamine at times like these, hoping it will make you feel good (interestingly, this can be a reason why people tend to do drugs and consume alcohol after heartache, it gives your brain the doors of dopamine it is craving for). Apart from that, as our brain also knows the very fact that they are not in our life anymore, it causes conflicts between what you know, and what your past behavioral patterns are. This causes the feeling of helplessness, as we know we want something, and can't get it anymore.
To change this just change your behavior patterns. Talk to someone you like when you feel lonely ( like your crush, a friend, your family), Do things you are passionate about, travel, talk. Do anything and everything (except drugs, if you don't want to ruin your life) to give your brain the necessary dose of dopamine so it doesn't crave it from that particular person. And with time, your brain will form new habits, connect your happiness to new things and people, and one day you will wake up and realize that you have moved on.