The New England Historic Genealogical Society (NEHGS), The Essex Institute, and others were commissioned to publish Massachusetts Vital Records up to 1850 for various towns in Massachusetts.
From AmericanAncestors (NEHGS): “At the turn of the twentieth century NEHGS was instrumental in introducing and passing legislation to appropriate funds to produce books of vital statistics to the year 1850 for the cities and towns in the Commonwealth of Massachusetts. …Not all Massachusetts towns are included.”
AmericanAncestors.com has a Massachusetts Vital Records to 1850 Collection that includes these commissioned books as well as some substitutes for towns whose vital records were not collected/commissioned. You can search by individual town volume.
Ancestry.com has these individual books available online and you can search by individual town volume.
FindMyPast.com has this collection available online searchable across the entire collection.
OnGenealogy.com has a list of the free, online Massachusetts Vital Records to 1850 books including a few substitutes for towns whose records weren’t commissioned. Most of these books are out of copyright and the versions not currently available online (for the towns of Ashfield, Charlestown, Eastham, Fairhaven, Harwich, Lowell, Marshfield, Milton, Montague, Otis, Pepperell, Sandisfield, Swansea, and Taunton) may still be under copyright.
If you’re trying to find free records for a town not included in this list, Internet Archive, Google Books, or HathiTrust are great places to start searching. Also try Massachusetts Births and Christenings, 1639-1915 at FamilySearch.
Best in your searches whether they’re fee or free!