Some people were already being enticed to idolatry via their Moabite girlfriends (Num 25), so idolatry seems to sometimes be intertwined with relations.
More specifically, Sanhedrin 82a brings the following (Soncino translation):
And Moses said unto the judges of Israel, Slay ye every one of his men that were joined unto Baal Peor. Thereupon the tribe of Simeon went unto Zimri ben Salu and said unto him, ‘Behold, capital punishment is being meted out, yet you sit silent [i.e., inactive].’ What did he do? He arose and assembled twenty-four thousand Israelites and went unto Cozbi, and said unto her, ‘Surrender thyself unto me.’ She replied, ‘I am a king's daughter, and thus hath my father instructed me, "Thou shalt yield only to their greatest man". ‘I too,’ he replied, ‘am the prince of a tribe; moreover, my tribe is greater than his [Moses], for mine is second in birth, whilst his is third.’ He then seized her by her coiffure and brought her before Moses. ‘Son of Amram,’ exclaimed he, ‘is this woman forbidden or permitted? And should you say. "She is forbidden", who permitted thee Jethro's daughter’? At that moment Moses forgot the halachah [concerning intimacy with a heathen woman], and all the people burst into tears; hence it is written, and they were weeping before the door of the tabernacle of the congregation. And it is also written, And Phineas, the son of Eleazar, the son of Aaron the priest, saw it. Now, what did he see? — Rab said: He saw what was happening and remembered the halachah, and said to him, ‘O great-uncle! did you not teach us this on thy descent from Mount Sinai: He who cohabits with a heathen woman is punished by zealots?’ He replied. ‘He who reads the letter, let him be the agent [to carry out its instructions]’.
According to this source, Zimri not only sought his own pleasure but sought to embarrass and perhaps displace Moshe and, by extension, the leadership structure put in place by God. When Korach tried this he was killed; so too was Zimri.