Central and Eastern Europe saw millions of people moved around in the aftermath of the Second World War, the largest population movement in history. Ethnic Germans were forced out of Czechoslovakia, Poland, Ukraine, etc., while Poland and Ukraine also saw people moved between them. This was not a peaceful exchange either, as several million people died in this forced migration.
There are a few reasons for it, but the most prominent was to solve the issues that plagued Europe in the interwar era, namely that national self-determination was difficult to implement if there were large minority populations. This was part of the justification Hitler used to annex Austria, the Czech Sudetenland, and Poland (note the regions he was after all had large ethnic German populations). To fix this people were transferred to their "homeland," even if they had never lived there or had been established in their previous location for centuries.
Ultimately it worked out though. For example Poland in the early 1930s was about 60% ethnically Polish, with the rest a mix of Ukrainian, Jewish, German, Belarusian, etc. By 1950 it was about 95% Polish (though this was also helped by the war killing off about 17% of Poland's population and the borders of the country shifting west). Similarly Czechoslovakia saw nearly its entire ethnic German population removed.
The Partition of India should be mentioned here. The end of the British Empire in India included a provision that India would be separated into two countries, Muslim-dominated Pakistan (which at the time included East Pakistan, what is now Bangladesh) and Everybody Else-dominated* India. This inspired a huge population exchange, as Muslims living outside the borders of Pakistan made their way to Pakistan, and non-Muslims who had always lived in what was soon to be Pakistan fled into the new country of India.
One of the reasons this was all a gigantic mess is that the borders were pretty arbitrary in terms of predominantly Muslim or predominantly not-Muslim** populations. So you had huge masses of people uprooted lest they end up in a theocracy dominated by a religion they didn't belong to.
I don't know as much about why Muslims in India emigrated to Pakistan, though I know that there was some violent retaliation against Muslims within the borders of India in sympathy with the people fleeing Pakistan. There also may have been economic, religious, or opportunistic reasons for Muslims to emigrate, not unlike why anyone leaves one country for another.
Here's a New York Times article on Khushwant Singh, who wrote the 1956 novel Train To Pakistan based on his own experiences of Partition.
Margaret Bourke-White took several iconic photographs of the population exchange. The link is a Google Image Search for them, because unfortunately I can't find a nicely curated website that shows them all.
A number of films have been made about Partition, though I'll admit that the ones I'm familiar with are Indian-made and thus go into a lot more detail about the atrocities visited upon Hindus and Sikhs. The best one I've seen is Deepa Mehta's Earth. There's also [Partition](http://en.wikipedia.org/wiki/Partition_(2007_film), which is a Bollywood movie from 2007, and a film adaptation of Train To Pakistan. There's a documentary called The Day India Burned, which I think is a BBC production, and which I've not seen. I'm not sure if there are films that tell the Pakistani/Muslim side of the story.
*I feel like people tend to assume that India was meant to be "Hindu", but that isn't strictly true. India was created as a secular democracy with no official religion.
**In addition to Hindus facing pressure to relocate, Partition was also a traumatic experience for Sikhs, and probably people of other religions as well.