What is the purpose of trademark law?

The overall purpose of trademark law is to prevent unfair competition by protecting the use of a symbol, word, logo, slogan, design, domain name, etc. that uniquely distinguises the goods or services of a firm. This body of common-law principles ultimately protects consumers by prohibiting companies from using trademarks substantially similar to those of other companies that may have more "brand equity" and customer loyalty. Trademark law is intended to avoid consumer confusion and preventing companies from diluting the marks of other firms. Dilution occurs when a similar mark adversely affects the reputation of a distinctive trademark regardless if it leads to consumer confusion or not.

Given the increased importance of branding and the tangible economic value of the brand (brand equity) in today's experience economy, trademark law is more important than ever before. As consumers become loyal to a particular brand and make purchasing decisions based on their ability to identify a product of service by use of a logo, slogan, etc (i.e. trademark), these marks serve as a point of differentiation and competitive advantage. Consequently, trademark law is important to enable the trademark proprietor to develop goodwill for the product or service and prevent other parties from exploiting the brand.

Reference:
[1] Stim, R. "Intellectual Property. Patents, Trademarks, and Copyrights" West Legal Studies.
[2] Black's Law Dictionary 5th ed., (West Publishing, 1979).