Alliteration is a rhetorical device (or figure of speech) in which a consonant sound is repeated in words that are near each other. Often misunderstood as necessitating that the alliterating consonants occur at the beginning of the words, alliteration can also occur when the repeated consonant sound falls on a stressed syllable anywhere in a word.
The most common alliterations in "I Sit and Look Out" use sibilant sounds such as "ss" and "sh." Look at the first line: "I sit and look out upon all the sorrows of the world, and upon all oppression and shame [...]." The words "sit" and "sorrows" alliterate on the first syllable with a hissing sound. This might create an atmosphere of unease, like a snake slithering through the grass. You might think the words "oppression" and "shame" also alliterate, but actually the "sh" sound in "oppression" does not fall on the stressed syllable. (This kind of repetition is called consonance; alliteration is a subcategory of consonance.) To figure out where the stressed syllable falls, use a dictionary. For example, the phonetic spelling of oppression in the Merriam-Webster Online Dictionary looks like this: "\ə-ˈpre-shən." The accent mark before the "p" indicates that "pre" is the stressed syllable.
Plosive sounds, such as "p" and "t," are made by a sudden release of air and can have a startling quality to them. In this poem, Whitman alliterates with them sparingly, probably to heighten their effect: "I observe the slights and degradations cast by arrogant persons upon labourers, the poor, and upon negroes [...]." This line (8) uses four plosives in quick succession: "persons," "upon," "poor," and "upon." This quadruple alliteration comes near the end of the poem and builds the earlier sense of unease sharply with sounds reminiscent of the rat-a-tat-tat of machine gun fire. These sounds may relate, then, to the theme of exploitation in the poem and the poet-speaker's reaction to what he is witnessing.
The sounds "m" and "n" are nasals. They are made, as the name implies, by forcing air through your nose. Here is an example from line 3 of the poem: "I see, in low life, the mother misused by her children, dying, neglected, gaunt, desperate [...]." The words "mother" and "misused" could be read as alliterating. However, Merriam-Webster's phonetic spelling of "misuse" is "\ˌmis-ˈyüz." You can see (because of the line before the /y/ sound) that "misuse" typically accents on the second syllable, and therefore the words would not be in alliteration. Yet readers could, in their interpretation of the poem, stress the first syllable, thus causing the two words to alliterate. In this example, the alliteration of "m" sounds could be mimicking the stuttering sob of the mother to elicit feelings of sympathy from the reader.
Alliteration, in poetry, is mainly used for stylistic effect. It can attract the reader's attention in order to reinforce meaning, link two words that might not obviously relate or provide mood and/or atmosphere (such as in the examples above). Lines 5 and 7 both have alliteration with "s" sounds: "[...] I see these sights on the earth [...]; I observe a famine at sea, I observe the sailors casting lots [...]." In line 5 the words "see" and "sights" alliterate. In line 7 the words "sea" and "sailors" alliterate. While the alliteration in line 5 does provide atmosphere (perhaps the sound of the waves breaking on the shore), it also draws attention to a homonymic pun between "see" and "sea": Although the two words are spelled differently, they sound the same. Perhaps this alliteration (which jumps over line 6) is meant to link the realms of land and ocean: When it comes to "meanness and agony" (line 9), there are no boundaries.