Why did St. Martin give half of his cloak, and didn't give the whole? There was a saint called St. Martin, from the city of Tours (France)
He gave half of his cloak to a poor he saw, because he felt pity for him, it was cold, and the beggar was more or less in rags.

I see the lesson in this story, but what I wonder is why he only gave half of his cloak, why not the whole coat?

I wonder if it was a real act, or an allegory (sharing when you have very little), but giving the whole wouldn't have been even more generous?

What is the (Catholic) Church's opinion about this story? Is this story known outside the Catholic Church?
Sulpicius (or Sulpitius) Severus was a younger contemporary of St. Martin, being 34 years old  when Martin died. He wrote, amongst other things, a biography of St. Martin. The story of the cloak is in Chapter Three. 

This chapter relates how, in an extremely cold winter, there was a beggar outside the city of Amiens, about 75 miles North of Paris. He is described as being "destitute of clothing" and was beseeching everyone who passed by to have compassion on him, but nobody did.  


  Martin, that man full of God, recognized that a being to whom others showed no pity, was, in that respect, left to him. Yet, what should he do? He had nothing except the cloak in which he was clad, for he had already parted with the rest of his garments for similar purposes. Taking, therefore, his sword with which he was girt, he divided his cloak into two equal parts, and gave one part to the poor man, while he again clothed himself with the remainder.


So Martin had already given away his other garments, which would normally be worn under a cloak. If he had given the beggar the whole cloak Martin would have left himself naked.

Severus goes on to describe the reaction of onlookers


  Some of the bystanders laughed, because he was now an unsightly object, and stood out as but partly dressed. Many, however, who were of sounder understanding, groaned deeply because they themselves had done nothing similar. They especially felt this, because, being possessed of more than Martin, they could have clothed the poor man without reducing themselves to nakedness.


It would have been possible for other people, who had not already given away their undergarments, to assist the beggar much more easily than Martin could.

That night Jesus appeared to Martin in a vision:


  In the following night, when Martin had resigned himself to sleep, he had a vision of Christ arrayed in that part of his cloak with which he had clothed the poor man. He contemplated the Lord with the greatest attention, and was told to own as his the robe which he had given. Ere long, he heard Jesus saying with a clear voice to the multitude of angels standing round— ‘Martin, who is still but a catechumen, clothed  me with this robe.’ The Lord, truly mindful of his own words (who had said when on earth— Inasmuch  as you have done these things to one of the least of these, you have done them unto me), declared that he himself had been clothed in that poor man; and to confirm the testimony he bore to so good a deed, he condescended to show him himself in that very dress which the poor man had received.


This is, of course,  a reference to Matthew 25:40.

OP asks if it was real or an allegory. There is nothing in the biography to suggest this was an allegory. It is told as something which really happened.

Even though giving the beggar the whole cloak would have left Martin naked himself, wouldn't that have been even more noble than just giving half?  

On St. Martin's Day, 11/11/2007, Pope Benedict XVI spoke before the Angelus of St. Martin:


  May St. Martin help us to understand that only by means of a common commitment to sharing is it possible to respond to the great challenge of our times: to build a world of peace and justice where each person can live with dignity


The Pope referred to sharing and dignity. Martin and the beggar both needed clothing. They had one cloak between them, so Martin decided they would share it. He treated the beggar as an equal, so each had half a cloak. How would the beggar have felt if he had been given the whole cloak, and seen Martin reduce himself to the beggars former position?  He would have felt embarrassed and undignified, a mere object of Martin's largesse. In sharing  there is dignity and equality. Martin did not say he didn't care about himself, he showed that he cared about the beggar just as much as himself. 

St. Martin did many things, but the incident with the cloak is by far the best known. It is a frequent subject in art, and as KorvinStarmast says, El Greco did a very famous painting of it.  In the Orthodox Church Martin is known as Martin the Merciful. His feast day is November 11th, and this day was traditionally marked across Europe in Protestant and Catholic countries alike. He is (I think) the only human saint whose day has a specific name in English: Martinmas.    It's position in the year was partly responsible as it marked the end of the harvest, New  wine was ready then, and indeed Martin is a patron saint of alcoholics. 

In Germany the carnival traditionally began at 11.11 am on this day. Martin had been a reluctant soldier and the  Armistice, bringing to an end the fighting in the Great War, took place on his day in 1918.