Overall meaning :
There are some people who worship Allah in a state of doubt and hesitation. When blessed with something good (such as good health and considerable wealth), they maintain their faith and worship; but when an ordeal befalls them, they renounce their faith, losing thereby both this life (by being deprived of peace and tranquillity and not having achieved what they were hoping for, among other things) and the hereafter (by their being made to enter it). That is indeed a clear loss.
Instead of Allah, they call on false gods which can neither harm them nor benefit them. That is the extreme deviation from the truth. They call on those whose certain harm is likelier than their inconceivable benefit. Evil and miserable indeed are their alleged protectors and associates!