Geeks get ostracized because other kids are more or less forced to compete with them for grades in school, and resent the fact that they come up short. This is as opposed to, e.g. jocks who mostly compete with other folks who've voluntarily chosen the same arena of competition.
Geeks get bullied because it's easy for people who are prone to bullying to bully ostracized kids.