"But what things were gain to me, those things I counted loss for Christ. Yea doubtless, and I count all things but loss for the excellency of the knowledge of Christ Jesus my Lord..." Paul is saying that the things which gave him exemplary standing among his peers ("being more exceedingly zealous of the traditions of my fathers." Galatians 1:14) really didn't do him any good in light of Christ and His love. He expresses it crassly as he continues: "for whom I have suffered the loss of all things, and do count them but dung, that I may win Christ." (Philippians 3:7-8)
An Apple a Day Keeps the Teacher at Bay
But think about the source from which those things he's mentioning sprung. They were delivered to Moses by God. And like humans do, they turned that stuff into a god. They decided to put the practice of the law above the lawgiver. Paul says "the law was our schoolmaster to bring us unto Christ..." Why? "...that we might be justified by faith. But after that faith is come, we are no longer under a schoolmaster. For ye are all the children of God by faith in Christ Jesus." (Galatians 3:24-26) In other words, we were always meant to be inwardly directed by the Holy Spirit. But until Jesus came and delivered, we had no access to Him. And Jesus says He came "to fulfil" the law and the prophets (Matthew 5:17)
But what about that incessant tug to "do right things"? Because we all have the ability to become lazy in both our faith and our life. I mean, in a very practical sense, were we to only eat those things that tasted-amazing-but-were-really-bad for us, our bodies would give out far before they were meant to. I don't have to do the law anymore (I never really did, to be honest). I never had to worry about the integrity of the threads in my clothes or purposely do nothing--because I had no choice--for half my weekend. These things weren't the way I was introduced to God. When my dad sat me down to "teach them diligently unto [his] children" (Deuteronomy 6:7 I also have a younger brother), he led with God's love. And with the simplicity of "acknowledging God in all my ways" against the potential misfired communication of "my own insight" (Proverbs 3:5-6). These things took years to build up as a framework around which the things of my innate nature and gifting could blossom and mold. To where anything I feel like doing--and this is where it ties in to the above passage--to where anything I might see as "gain to me" were seen through the lens of Christ and His love.
This is what caused and this is what affects me. And what, I hope causes effects in others.
Causes, affects
"But as many as received Him, to them gave He power to become the sons (and daughters) of God, even to them that believe on His name: Which were born, not of blood, nor of the will of the flesh, nor of the will of man, but of God." (John 1:12-13)
The Greek word translated into English up there as "power" is exousia. It carries the connotation of "right" and "privilege". The thing about knowing Jesus is realizing that He has indeed "seen and done it all". Audacious and irrational as that may sound, it's true. And He gives us the opportunity, and indeed that atmosphere of the Holy Spirit to where we get to do things for Him. There used to be strict qualifications on living for and unto God. David superseded a lot of it as "a man after God's own heart". He got it even then. Just read through the Psalms and tell me if it sounds like someone who was strictly and dryly doing his best to eke out an existence under the weight of a bunch of rules. Rules, that, one doesn't really feel like doing anyway.
In closing, this is what Paul was getting at:
"And be found in Him not having mine own righteousness, which is of the law, but that which is through the faith of Christ, the righteousness which is of God by faith: That I may know Him, and the power of His resurrection, and the fellowship of His sufferings, being made conformable unto His death;" (Philippians 3:9-10)