The Forbidden City itself did not prevent European influence on Chinese culture, but "all it represented" did.
We can say that the Forbidden City represented the idea of the supremacy of the Chinese emperor and of Chinese culture in general. It represented the fact that China saw itself as the "Middle Kingdom," a place that was superior to the other parts of the Earth. When a country holds to this sort of an outlook, it will be very difficult for outside influences to penetrate. The people of the country, particularly the elites, will see themselves as superior to all others and will not think there is any need to adopt foreign ways.
Thus, the ideas and attitudes that the Forbidden City represented did a great deal to keep European influences out of Chinese society and culture.