Read Having the Peace of God, by Jack Kelley, at Grace thru Faith.
Here, Jack answers this question: "Hebrews 13:5 says that God will never leave us nor forsake us, but Philippians 4:9 says that God will be with us if we continue to do what God tells us. How do I reconcile these verses?"
"These verses are meant to be taken as a single stream of thought, the focus of which is achieving the peace of God that transcends human understanding."
Rejoice in the Lord always; again I will say, rejoice! Let your gentle spirit be known to all men. The Lord is near. Be anxious for nothing, but in everything by prayer and supplication with thanksgiving let your requests be made known to God. And the peace of God, which surpasses all comprehension, will guard your hearts and your minds in Christ Jesus. Finally, brethren, whatever is true, whatever is honorable, whatever is right, whatever is pure, whatever is lovely, whatever is of good repute, if there is any excellence and if anything worthy of praise, dwell on these things. The things you have learned and received and heard and seen in me, practice these things, and the God of peace will be with you.
Philippians 4:4-9