Bilaam wasn’t successful at cursing the Jewish people due to their modesty so him and Balak decided to bring Midianite & Moabite women to seduce the Jewish people. Unfortunately some people fell into the trap and Pinchas took responsibility for the rest of the people and dealt with the situation face on. Because of Pinchas, the Jewish people were saved and G-d granted him Priesthood.