The Torah [Vayikra 23:15- 16] says: "U'sefartem lachem me'macharas ha'Shabbos mee'yom havayeschem es omer ha'tenufa sheva shabasos temimos t'heyena. ad mee'macharas ha'Shabbos ha'sheveeis tisporu chameeshim yom (You shall count for yourself from the day after Shabbos; from the day when you bring the Omer of the waving, seven weeks they shall be complete. Until the day after the seventh week you shall count fifty days)". Elsewhere [Devarim 16:9] the Torah writes "Shivah shavous tispor luch (seven weeks you shall count)."
During the time of the Bais Hamikdash, when the korban omer was brought on the 16th of Nissan, there was a mitzvahme'deoraisa to count 49 days from the day the korbanomer was brought until Shavous. Nowadays, that we sadly do not have the Bais Hamikdash, there is a machlokes whether the mitzvah to count remains a mitzvahme'deoraisa or is a mitzvah me'derabanun [enacted as a zecher l'mikdash (a remembrance to what was done in the Bais Hamikdash)]. Most Poskim hold that it is me'derabanun (Be'ur Halachah 489:1 s.v. lis'por).
The Sefer Hachinuch  explains that the reason for this mitzvah as follows: The primary reason why the Jewish people were redeemed from Mitzrayim was in order to accept the Torah and to keep it. Therefore, Hashem commanded us to count, beginning the 1st day after we were redeemed [which is the 16th of Nissan, the Jewish people left Mitzrayim on the 15th of Nissan] up until the time that the Torah was given at Har Sinai [on Shavuos], in order to show how much we anticipate reaching the time when the Torah was given. As an aside, the Sefer Hachinuch [ibid] adds that the reason we start counting up from number 1 and not from 49 and down is because we do not want to start off with a big number since it appears that Shavous is very far away. However, once we already start counting up we continue counting this way until the end.
Similarly, the Medrash explains that the korban omer consisted of animal food [barley] and the korban that was brought on Shavuos consisted of human food [wheat]. Hashem was showing the Jewish people when they left Mitzrayim they were on a low spiritual level comparable to an animal. Only after they received the Torah were they considered people. Therefore, when counting we count "to the omer" to realize that without Torah we are comparable to an animal (Aruch Hashulchan 489:3).
Men are obligated (Shulchan Aruch 489:1). Women are exempt, since this is a mitzvas asei she'hazman grama (time bound mitzvah) (Mishneh Berurah 489:3). However, the common custom is that women do count, similar to other mitzvos asei she'hazman grama that women generally perform. [For example, listening to shofar, eating in the succah and shaking the daledminim] (Aruch Hashulchan 489:4). The Mishneh Berurah [489:3] writes that the custom where he lived was that women count, but without reciting a brachah, since they generally do not understand what they are counting and also many times forget to count. It is important to note that many Poskim hold that nowadays these reasons do not apply since it is common to have many reminders [for example, sefiras ha'omer calendars and electronic reminders]. Accordingly, some say women should count with a brachah (Koveitz Halachos 1:2 & ftnt. 2). Children, who have reached the age of chinuch, should be taught to count. A child who skips a day should continue counting without a brachah, just like an adult (Koveitz Halachos 1:3).
There is an opinion that holds that it is preferable that one should count himself and not fulfill his mitzvah by listening to someone else. Therefore, ideally each person should count for himself (Mishneh Berurah 489:5).