They originated in Mexico between 5000 and 8000 BC, and nowadays are eaten all over the country, sold as a street snack for any meal of the day. There are hundreds of regional variations (including sweet dessert tamales) and are starting to spread worldwide.
Sources:
Wikipedia
Rico Mexican Kitchen