In literature, it is not uncommon to use language to call attention towards itself (figures of speech), and to how things are being said. The writer has to catch the attention of the reader, and to use proper devices for this goal.
When language is being used to create beauty, to call attention towards itself, the poetic function is at work. The important thing is not so much what is being said but how it is being said. The writer intends to arouse certain sensations on the reader, of beauty, creativity, and originality, through the form of his or her message. Every expressive resource is valid. This function appears on colloquial language as well; everyone selects consciously or unconsciously the words, voice inflexions, and the types of sentences to use when building an efficient message for what one tries to communicate.