A user's karma reflects how much a user has contributed to the Reddit community by an approximate indication of the total votes a user has earned on their submissions ("post karma") and comments ("comment karma"). When posts or comments get upvoted, that user gains some karma. You can see how much karma a user has on their profile page.
The best way to gain karma is to submit posts that other people find valuable and interesting and commenting on posts with insightful content. Being on-topic, relevant, funny, interesting, or engaging are great ways to earn comment karma. Being insulting, rude, or abusive is not. Snark can go either way.
You do not earn karma from your own default upvotes on your submissions and comments, only from other people's votes. In other words, you can't earn karma just by submitting posts or writing comments - other people have to vote on those posts and comments.
Karma is only approximate: there is not a 1:1 relationship with votes. Your post karma will always be significantly lower than the total number of votes you receive on your links. Comment karma is closer to a 1:1 relationship, but is still only approximate.
Don't set out to accumulate karma; just set out to be a good person, and let your karma simply be a reminder of your legacy. Note: Reddit makes no guarantees about attaining Nirvana.