The pasuk says in Sefer Melachim I (12), כי היתה סבה מעם ה' - "the cause was brought about by Hashem."
The Hovot Ha'levavot teaches us that we need to train our minds to realize that Hashem is the cause of everything that transpires. Imagine a person who walks into the synagogue one morning looking thoroughly exhausted, and his friend approaches him to ask if he is alright.
"I hardly slept last night," he replies. "My neighbors are away, and their alarm went off the whole night. What nerve! Now my whole day is ruined."
It appears, at first glance, that the cause of his exhaustion is the alarm. If the alarm hadn't malfunctioned, then the man would have gotten a good night's sleep. In truth, however, היתה סבה מעם ה' - Hashem decided that this man should have his sleep disturbed, because - for reasons that only Hashem knows - this was the best thing that could happen to this man. Hashem therefore caused the alarm to go off as the means through which this man would be unable to sleep properly. The correct response to the friend's question would be, "Baruch Hashem, everything is great. Hashem wanted me to be awake last night, and this is why I look tired. I know this is the best thing for me, so I am not upset at all."
Imagine a person has an excruciating toothache, and three hours later he realizes there is a medication he could take to relieve the pain. He goes to the store, buys the medicine, and takes a dose, and soon thereafter the pain is gone. It appears, at first glance, that this person devised a way to take away the pain, and if he hadn't thought of this solution, he would have still been suffering many hours later. But this is not what happened. The truth is that Hashem decreed, for this man's ultimate benefit, that he should experience severe pain in that tooth for precisely three hours, 47 minutes and 28 seconds. Therefore, three hours after the pain started, Hashem put the thought in this person's mind that he should take the medication, knowing that it would take him 27 minutes to go out and buy it, and then another 20 minutes for it to take effect.
Everything happens precisely the way Hashem planned. Nobody experiences a second more pain than the amount decreed by Hashem. And it is not the medication that relieves the pain; it is Hashem, who camouflages Himself behind the veil of nature.
Everything we see is just another messenger sent by Hashem to fulfill His will. If a person enters a business and earns a lot of money, but then, due to unforeseen circumstances, he is forced to close the enterprise, he might start thinking that if he had done things differently the business would still be running successfully. But the truth is היתה סבה מעם ה' - Hashem decided that this person should earn a certain amount of money from this particular business, and so at the right time He gave him the idea to open this business. When the specified amount of money was earned, Hashem brought about the circumstances necessary to close the business.
All aspects of our lives are determined solely by Hashem - except for matters of spirituality, regarding which it is our job to excel. The decision of whether or not to perform a certain mitzvah, or whether or not to do a certain favor for somebody, is entirely up to us. And it is only regarding these areas that regret is justified. When it comes to mitzvot, we are to consider whether perhaps we acted improperly or did not extend ourselves as much as we should. We are supposed to harbor thoughts of teshuvah, thinking, "Perhaps I could have done this mitzvah better," and once we properly perform teshuvah, Hashem erases our sins and gives us a fresh start.
Hashem takes care of our physical and material needs, so we should leave these aspects of life in His hands, and concentrate more on spirituality and self-improvement - the area which He left to us.

