is a grammar pattern that indicates that something is ‘contrary’ to what has previously been said. This is a structure made up of the noun 逆（ぎゃく） ‘reverse’, ‘opposite’, or ‘converse’, and に. Due to the inclusion of に, this phrase behaves adverbially, and will usually appear between two phrases, to indicate that ‘on the contrary to (A), (B)’, or ‘conversely to (A), (B)’.
You may think it is safer to wear gloves, but on the contrary, it is dangerous because they could get caught in the rotating parts. So, please remove your gloves before working.
I thought that it was a shortcut, but on the contrary, I found out that it was actually a detour when I checked on a map app.
I broke the spaghetti in half to make it easier to eat, but on the contrary, it made it harder to eat.
In modern Japanese, 逆（ぎゃく）に
is also frequently used at the beginning of a sentence, simply to indicate a rebuttal toward something that someone has just said, or as a slang version of 別（べつ）に when asked questions about preferences, or similar things.
On the contrary, how old do I look?
I don’t care too much what we eat, how about ramen?