Part of the reason for inserting notes of dissonance within any musical piece would be to enhance the overall tonal quality of the work. Discordant notes awaken the audible sensibilities of the listener, and, in many ways, can begin a sense of questioning about the music. How the notes were inserted, why they were placed, and creates a level of potential "uneasiness" in the work, allowing the listener to actually become more engaged in the listening process. From the composer point of view, these notes' inclusion represent something more than the purely harmonious sounds in any piece. On a more symbolic leve, these notes' inclusion could serve to represent a theme or an idea that is seeking development on the part of the composer.
Discordant notes are a kind of musical spice.
Most people like the taste of mayonnaise in their food, and most people enjoy vanilla ice-cream for dessert. But imagine if every night your dinner was made with mayonnaise, and every night your dessert was vanilla ice-cream. Boooooring, right?
Your meals need spice. Sometimes salt and pepper, sometimes curry, sometimes burning-hot jalapenos. And then sometimes, when you go back to good-old mayonnaise and vanilla ice-cream, you'll appreciate that more, too.
Music is the same. A steady diet of C-chords is pleasant but boring. A flatted fifth (G-flat) in the middle of a C-scale is a little spicy and mysterious. Duke Ellington was known to arrange pieces that had a bass instrument play an E at the same time that an alto saxophone played an F--two notes that are right next to each other and are not part of any "normal" chord. The result: interesting, spicy, attention-grabbing, unforgettable.
Of course, you can go overboard. A piece that has nothing but discordant notes can give you a big headache. Unless you're interesting in creating a musical replica of a headache, it's best to compose using a reasonable balance of both harmonious and discordant notes.