Spiritual contentment is of God and can be learnt through practice and discipline.
This passage is autobiographical. Paul wants us to know his experience in being content in every situation. The Bible is pointing to the work of God in the reality of our lives.
In every circumstance there are duties that can be fulfilled for God. God is bigger than any circumstance.
Contentment doesn't mean complacency. You can be content and still desire a change in your circumstance. We are given many examples of people praying for a change and being content with whatever answer God gives. God wants us to trust in His will and to grow with Him.