It implies that the person is not present mentally and their actions or statements don't make sense. It's like they've gone off on a mental tangent and lost touch with reality.
Here are some examples:
* "He's been acting so strange lately, he must be completely out to lunch."
* "That was a ridiculous proposal! They were out to lunch to think it would work."
* "She's been out to lunch ever since she started that new medication."
The idiom originally referred to someone who was literally out to lunch, but it has evolved to be used figuratively to describe someone who is mentally absent.