The Zondervan Academic blog explains the significance of words of Paul that are often taken out of context:
Just before Paul says, “I can do all things through Him who gives me strength,” he recounts some of the different circumstances he’s found himself in: he’s been hungry and well-fed, he’s been in need and he’s been well off, and he’s learned to be content, no matter what his circumstances are.
Paul isn’t juxtaposing these circumstances to suggest that one is better than the other. He’s using these extremes to highlight that he understands the range of human experience, and that he understands the challenges that come with each position. He isn’t a rich person telling a poor person to be happy with what they have (or vise versa), and he’s not sitting there on a full stomach telling hungry people to get over it.
He’s saying that no matter what your circumstances are, you can learn to be content. How does he know? Because he’s tested it, and he’s proved it. How does he do it? That’s where verse 13 comes in.
If you read the NIV translation of verse 13, you’ll notice an important distinction from most other translations:
“I can do all this through Him who gives me strength” (emphasis added).
When we read “this” instead of “things,” it’s a lot more clear that the passage is referring to specific things—all the things Paul has been talking about—not “all things” in the sense that we can do anything.
See also the post on the Zondervan blog on why Paul wrote Philippians.