To befriend the Underpants Gnomes, you must complete their side quest to find 5 pairs of underpants. The underpants can be collected at any time, however the sidequest with the Gnomes only becomes available after you finish the story quest related to them at the start of Day 3. The underpants are located:
1. In Cartman's room
2. In Stan's room
3. In Stan's parents' room
4. In Kevin Stoley's room
5. In Kyle's room (must progress in the story)
To befriend the Crab People, you must acquire the final fart spell, Nagasaki, from Terrence and Phillip in Canada, which is near the end of the game. Then you must go all the way to the end of the sewers (or enter next to the movie theater if you've opened that manhole) and break the rock with your Nagasaki. This will clear the path to the Crab Person, who will friend you after talking to him.