I could never understand this practice until a friend of mine explained this to me. I had learned that one does not need anyone or anything to connect to God and to pray to God in Islam. But as I traveled in Muslim countries and made Muslim friends, I saw them praying for and wishing peace upon not only prophets but also saints and people in history who were known to be good Muslims. This seemed like a contrary thing to do in my view.
One day, though, my friend explained to me that there are some people who are closer to God than others in the sense that God is especially fond and happy with them due to their virtues as a Muslim. Muslims are not asking for things from God through other people, but rather hoping that these people's special status will have some benefit on them also.
So when Muslims say "Muhammed, peace be upon him," they are actually helping themselves. Wishing for one of God's favorite people to have peace, is also a sign of devotion to Allah.