Optocouplers for purposes other than galvanic isolation?
I don't think it's productive to ask "what are these for?". The reason I don't think it's productive is that frankly I don't think the designer had any idea what he was doing. Putting an optocoupler in the B module - well, sort of. Trying for noise immunity, I guess, and maybe level shifting, as has been mentioned. Driving it with an optocoupler in the A module is just silly.

I suppose the lightning hypothesis is the best bet, but with both common ground and common power acting to lead any such surges back into module A, it's wasted effort.