A colleague at work asked me why Jews are not buried alongside Non-Jews. He understood why we don't eat with them, but thought those differences should not extend in death and pointed at the cemeteries for U.S. soldiers which have the fallen integrated by battle, not religion. I told him that we are supposed to be selective even about who is buried nearby (i.e., a Rasha not being buried near a Tzaddik), but I was hoping to uncover a reason behind the halacha.
See Sanhedrin 47a with Rishonim, especially Ramban. Exhaustive treatment of the subject may be found in these two issues of דף קשר הר עציון.
A detailed overview of the prohibition by Rabbi Avihud Schwartz
The gemara applies the rule of אין קוברים צדיק אצל רשע only to people executed by beis din. There is a machloket RaMBaM and RaMBaN which is taken up by others as to whether or not it applies elsewhere and if so, does it take into account various levels between prophet-level tzadikim and capital punishment-level reshaim? The author concludes with the rulings of Chasam Sofer and Minchas Yitzchak that it does on all counts and that it should apply equally to contemporary Israeli chilonim, contrary to the ruling of Chazon Ish.
Further perspective and psak regarding when to apply the rule
The rebbi of the author of the first article, Rabbi Yaakov Medan, argues that the Chasam Sofer's ruling was never accepted for reasons mentioned in his own teshuva. Furthermore we do follow the ruling of Chazon Ish not to treat contemporary Israeli chilonim as mumrim and the current trend among certain rabbanim to begin doing so now is reprehensible both morally and halachically and is bad for the Israeli society and the Jewish people from a practical perspective. (Rav Medan is known for being very strident).
For context, these articles were written shortly after a minor scandal in Israel where someone was exhumed because his family felt it was inappropriate for him to be buried near nonobservant Jews.