事に is not placed at the end of the sentence. The full sentence is
XXXに首を突っ込む is a set phrase. It means "to meddle into something." It is almost equivalent to English's "poke your nose into something that is none of your business."
You can understand the sentence as
It's bad to excessively poke your nose into dangerous things.