Understanding principles of music theory can help you compose music. You should know about scales, chords, key signatures and rhythms. Knowing how to write music using the staff and clefs also enables you to notate what you write. When you realize what chords work well together, you are much more readily able to fit a harmony with a melody. For instance, using the common progression I-IV-V-I in any key can provide a simple harmonic underpinning of your melody. Picking a scale gives you a set series of notes to work with and can make composition easier. Understanding basic orchestration can also help you know the range of instruments and how instruments are used in an arrangement.
There are many ways to ease yourself into composition. For instance, pick a common melody and write your own harmonies to it, or write different lyrics to a song you know well. Choose a scale so you know which notes you can pick from. Write a melody first, then choose how to harmonize it. Much of writing music is simply making decisions. When you come to rest on a note, think about the harmony underneath it--choose a chord that has the note in it already for a more consonant sound, or choose a chord without that note, which can create a more dissonant sound. Music is all about tension and resolution; create tension with the harmonies, and you can choose whether or not to resolve it.
Arranging music in different ways can make a song or piece of music more interesting. For practice with arranging music, pick a melody and the instrument that will play the melody. Write the chords for the harmony and choose which instrument will play which note of the chord. You may have to use inversions of chords for better voicing among instruments. Also, think of one instrument group for providing the harmonic pad, and another instrument type will play the melody. For instance, if you can write for a large ensemble, do not have the strings play the melody and the harmony; have the strings play just the harmony and perhaps a woodwind play the melody. Use different rhythm patterns for the accompaniment or harmony to make it more interesting.
You do not have to know all about music or be professionally trained in the art of composition to write a song or other piece of music. Understanding music theory certainly helps with the process, and it can help you make more informed decisions and offer a reason why you chose a particular note or chord. Writing is also trial and error. Do not be afraid to make edits to your work. Feel free to improvise before writing anything down. Writing often also improves your craft.