A composer invents pieces of music and writes them down. The word compose comes from the Latin word for to put together. An older German word for composer is Tonsetzer" or French Compositeur.
People have been making music since ancient times and the Middle Ages. People have tried to write down notes. Often we don't know who came up with a melody in the past. It was not until about the Renaissance that there were famous composers whom we know by name even today.
Famous examples of such composers are the Germans Johann Sebastian Bach, Ludwig van Beethoven and Johannes Brahms, the Austrians Wolfgang Amadeus Mozart and Franz Schubert, the Frenchman Claude Debussy, the Italian Giuseppe Verdi, the Russian Igor Stravinsky and many others.
Whoever has written a piece of music has the copyright for it. He should also be able to earn money from it. For most composers, however, it has always been difficult to live only from composing. Many were also musicians who played their own or other people's pieces for listeners.
Composer is a profession that can be studied at a university. But there are also composers who write pieces of music in their spare time, when something occurs to them.