When you start a game at some point, either right away or after a bit in the games progression you'll be prompted to turn on streetpass functionality. Once you do some data is saved to your 3DS. This data is different from game to game - for example in Fantasy Life it's your character, their stats and armor, their wish, and their greeting.
When your 3ds is closed and turned on (termed: Sleep Mode) and you have wifi turned on and then you come in range of another 3ds that is also closed, turned on, with wifi enabled: you will receive their streetpass data. They will also receive your streetpass data.
Most games can accumulate quite a few streetpass es before you need to go in and clear it out. That is, the limit on pokemon is 99. So when I pass my girlfriend I have 1/99. When I check the streetpass data in game I have 0/99. If I pass 99 people before I fire up pokemon again, the 100th, 101st, 102nd, etc. Won't have their data registered.
One way different exertion is the streetpass plaza games - the limit on the plaza is 10 so when you have 10/10 you should go in and get those puzzle pieces, slay those monsters (water plants? Grow army? Explore haunted house? Shoot aliens?) if that's something you're interested in. Because that 11th person won't count otherwise and you'll miss out on a puzzle piece! (Or a hero, or a plant waterer, etc.)
SOME places (McDonald's, best buy, home depot) are streetpass relays. So when you go there your data is "stored" on their special router. It will give out your data to the next three people that pass by and the router can store a lot of people. You can only receive 6 streetpasses in one trip at the same relay station.
It has occurred that two people will walk by a third with a 3ds and 2 will get a streetpass and one will not. I dunno. WiFi gremlins I guess. Also sometimes me and my girlfriend will go to McDonald's and only one of us gets streetpasses. Again. Weird quirk, who knows.
Also some weekends are international streetpass weekends. Now relay stations aren't tied to locations! When you visit a relay station you can get streetpasses from ANY OTHER relay station IN THE WORLD. It's pretty neat!