This section of 1 Corinthians could appear to be two completely unrelated thoughts. The challenge comes in one little word which links the two lines of thought, therefore. I have heard it said and have taught whenever we see a therefore in the text, we should as what is it there for.
In this case, Paul is reminding the people and us, of our story. Upon even a basic reading of the Scriptures we find the story of humanities journey is told over and over. We must remember our story, in hope that we will not repeat it. Unfortunately all too often we do lose touch with our story, not just our personal narrative, but our story as the created of God. When the story is forgotten, we forget who is writing the story, and what happens when humanity tries to take control of the story.
Paul encourages us to remember our story so we will not lose our freedom. That is how the two apparently unrelated pieces come together. When we lose sight of our story we lose sight of the freedom we have been given. Now this is not freedom to do whatever we please. This is freedom to experience the fullness of God. The truth is we can do whatever we want, yet not everything is beneficial, or helpful in experiencing the fullness God has called us to.
Participating in culture is not prohibited, that is the whole meat to idols conversation. What is prohibited is causing another person to stumble. We must remember this person could be ourselves. We are to live a life connected with the culture around us, as long as that culture does not become what shapes our values. It is God and God alone who should be shaping our values. This is why we must remember our story.