Everything happens for a reason
Sometimes you know that you have to make some changes in your life and you don't do it or you take too long to do it. Because it's scary, because you have to go outside your comfort zone and it's so comfy to stay in it. A lot of people are scared of taking risks and going outside their comfort zone so they stay in a situation they're not happy with instead of freeing themselves from it.
So the Universe (or life, God or whatever word you want to call it) forces you to make that change so you don't miss out on what it has planned for you. It never happens in a nice way, it is always a very difficult time when it happens that way but it is to free you from a situation, people or whatever was not good for you anymore so you can move forward to what is best for you and meet the right people for you or be with the right person for you.
And then after a while (or pretty quickly depending on how long it takes you to understand) you realise it was the best thing that could have happened to you and that it happened at the right time. And you are grateful for it.
Learn to notice the signs, they are always there. Listen to your intuition instead of you mind/ego. If you're not happy in a job, leave it. If you're not happy in a relationship, leave it even if you love or care about that person. If you're not happy they won't be happy either and there is someone better out there for both of you so stop preventing both of you being happy with the right person. If you're not feeling happy in your life it is because changes are needed. Take a leap of faith, the Universe has your back.
(ps: if you do bad things to people, wish bad things to happen to other people, then when bad things happen to you it's just karma. Always remember about karma and the law of attraction).