Why this code wasn't written in a much simpler way?
You are right in that it appears the code you show is silly.  Perhaps whatever machine this runs on can't do immediate operations to set bits on I/O ports, and that that's why something like SETB P2.2 isn't possible.

Still setting the CY bit to 1, then ORing anything into it is just plain silly.   The same goes for setting the CY bit to 0, then ANDing something into it.  Clearly the CY bit can be directly copied into a I/O pin bit, since the code does that.  At most this should be 4 instructions, certainly not 6.