A simplistic answer is that "ich" is analogous to "I" and "mir" is analogous to "me". Just as you say in English, "with me" (rather than "with I"), in German you say "mit mir" (rather than "mit ich"). Similarly, you say "mit dir" ("with you") rather than "mit du" in German.