The reason Lennie hallucinates at the end could be a combination of factors. It might be his intense longing for a different outcome, his internal conflict, and the overwhelming sense of loss and fear.
It could be due to his mental state and the stress of the events. Lennie's mind was already fragile, and the culmination of everything might have pushed him over the edge, causing hallucinations.
Perhaps Lennie hallucinates because he's unable to cope with the reality of the situation. His deep attachment to certain things and his fear of the consequences might have led to this psychological break.