Although we may not understand or even want to understand at the time, everything happens for a reason. Of course we won't be able to see it as it happens, but every occurrence in our life changes the path we are on. Life is going to be full of ups and downs, we just have to keep pushing forward no matter what.
It's easy to see this when we look back on our lives. You can see points in your life when something major happens and then see how it leads to things you did later or even how it has led you to the point you are at now. You can see how relationships that ended have led you to your current relationship or how upheavals at work have led you to your current job. At the time, things which seemed like the end of the world probably opened more doors for you to get to where you are.
Remember this, when things seem to be bleak or you just can't make sense of where you are in life. We will never know the future and we will never know how what we do today will change what we do tomorrow. We can't connect the dots, except when we look to the past. Just keep pushing and things will work out, maybe not today, but if you give it your all, things will work out in the long run.