The original question had to be edited. I would suggest that one area of similarity between both works is that they depict a world where evil does exist. For Whitman, this comes in the form of the various injustices observed. The speaker attests to viewing "all the sorrows of the world, and upon all oppression and shame" that is in consciousness. This can be specifically understood in the "mother misused by her children" and "the wife misused by her husband." Whitman also extends this into the realm of the political with injustices seen in "martyrs and prisoners" and " the slights and degradations cast by arrogant persons upon laborers, the poor, and upon negroes." This is the state of being that surrounds the speaker.
In Lennon's work, the same form of depicting injustices is evident. Lennon is compelling the listener/ reader to "imagine a world" where the injustices he describes are absent. For Lennon, the need to imagine arises out of a setting in which "hell below us" and "possessions" or "greed or hunger" have caused some of the worst in human treatment. The fact that he asks to imagine a world in which people "live in peace" speaks to the perpetual state of conflict that subsumes human beings. Lennon's song echoes Whitman's statement of being in which "All the meanness and agony without end" is demonstrated.
Both poems articulate a condition in which the world is crying out for change. Both writers speak to what is and seek to evoke a response where what can be is evident. While I think that Lennon's song is more demanding in its call for action in its stated lyrics, Whitman is compelling the reader to think about the events depicted and construct meaning in seeking to bring about change. Both poems are concerned with how reality is formed. Social transformation in both can only begin with complete disclosure about the state of nature which necessitates change.