From doing some research on this, if I remember correctly, it seemed that there were false teachers in the Pergamum church (Rev 2:14-15) enticing those who belong to God to engage in activities that were not of God. Twisting God's instructions to engage in immorality and through this immorality (which is often connected to idolatry) move into idol worship (or worshiping demons).
The Pergamum church was smack dab in the middle of some intense, idol worshiping culture, with heavy pressure outside the church to join (persecution). From the inside of the church were those who held to the teaching of the Nicolaitians who it seemed enticed some (or tried to) of the church to engage in idolatrous immorality, supposedly ok because of their freedom in Christ. Much like Balaam who for money and interest of others against Israel, enticed Israelites outside God's bounds of instruction; these Nicolaitians, through false teaching, enticed people in the Pergamum church and put a stumbling block before them, going outside God's bounds of instruction. Of course, any who participated also brought funding to the temple of the idol being worshipped in immorality. And this was Balaam's motive, money.
With Israel, these actions put her in the position of opposition to God, exactly where satan wanted. The same tactic was being used through misapplied teachings of God, and even more so perverse in using God's word as the supposed viable reason in Pergamum.
And then, there's that monkey see monkey do effect probably kicking in to a certain extent. This is where the 'teaching' gains a foothold in the door of the church so to speak and allowed to grow because it seems the leaders, for whatever reason, tolerated this teaching. And indeed this church was in danger. In reading in Revelation 2, Jesus speaks of these things He has against Pergamum and gives a warning to stop and speaks of reward to those who overcome.
Peter's admonishment about how to use our freedoms in Christ is very applicable:
Live as free people, but do not use your freedom as a cover or pretext for evil, but [use it and live] as bond-servants of God. 2 Peter 2:16 AMP