The analogy for Diffie-Hellman (probably the simplest well-known cryptosystem) that I've always liked is imagine we could encrypt messages using paint. Imagine that if we could get the exact same shade of a particular color of paint, then we could use that to encrypt messages. Now to get there:
1. I come up with one color of paint (say red), you come up with another color of paint (blue), and together, we agree on a third, public color (yellow). We keep our own colors secret (even from each other).
2. I mix my color (red) with yellow to get some particular shade of orange; you mix your blue with yellow to get some particular shade of green.
3. I send you the orange, you send me the green, and then I mix my own red with the green, and you mix your blue with the orange. We never had to publicly post our private colors (red and blue), but now we have the same color, because when I mixed red and green, what I really did was red+(blue+yellow), and when you mixed blue and orange, you got blue+(red+yellow), which is the same. Everyone can see the shades of green and orange we exchanged with each other, but if they try mixing those together, they end up with red+yellow+blue+yellow, which has too much yellow in it; and the assumption is that it would be hard to separate out the original colors in the colors seen publicly. (Everyone can see that we traded orange and green with each other and that our public "base" color was yellow, but that's not enough information for them to actually recover the original shade of red and blue that we used, because there's no easy way to subtract paint colors.)
The idea behind Diffie-Hellman is to do that, but with numbers instead of paint. You want to find some hard-to-reverse process (like separating paint colors after they've been combined) so that each person can start with a secret number, combine it with a publicly known number, trade the result with someone who has done the same thing (with the assumption that it's really hard to recover the secret after it's been combined with another number), and then combine your original secret number with the number they gave you. The takeaway is that you now have a shared secret even though all of your computations were either a. public to everyone, or b. private entirely to yourself (not even visible to the person who ends up with the shared secret with you). Once you have a shared secret, you can use that to encrypt your messages, and only you and the other person will be able to read them.