We’ve talked a little already about how some melodies are more idiomatically correct for certain instruments, but that’s just scratching the surface of the importance of orchestration. Below is a list of considerations that you should think about when assigning the melody to an instrument:
What is the character of the melody?
Is it light and bouncy? If so perhaps a woodwind, pitched percussion instrument, or violin is the appropriate instrument.
Is it dark and brooding? If so maybe it should be performed by a tuba, double bass, or French horn.
In general, try to match the character of the melody with an instrument that has similar traits. Remember that the sound of an instrument can change greatly depending on its tessitura (or range).
Does the melody have any limiting technical demands?
If your melody is a complex set of arpeggios and blazing fast notes then it would be unwise and unkind to ask most tuba players to play it, but a flute player might jump at the opportunity.
If the range of your melody is extremely wide then you’ll need to find a instrument with an equally wide range, or you’ll have to spread it across multiple instruments in the ensemble.
If your melody contains extremely long notes or has no easy place to breath you would want to avoid giving it to brass players.
How does this melody fit into the overall story of your piece?
Are there specific characters represented by different motifs (like in Wagner or Star Wars)? If so the you might want to consider grouping those motifs by instrument too.
Is there a specific mood your melody is trying to convey that isn’t obvious just from its characteristics? Sometimes its necessary to give an instrument a melody that is outside of its typical characteristics for creative purposes. A light and bouncy melody might sound “ironic” when performed by a tuba or double bass.
For further study:
Check out Peter and the Wolf by Prokofiev for a masterclass in assigning melodies based on instrument characteristics.