Because despite agreeing to the rules that say no profanity, some people break those rules. It gives parents an option to add one more layer in place.
The filter, like most filters, is not perfect though and can mess with typing normal words. Many people turn it off for that reason. Not so they can hear things that the game already prohibits. This thread, like many for the past 17 years, explains that. Spotlight on: Harassment
Mature Language Filter (aka The Profanity Filter)
This can be activated within your Interface Options: Main menu (ESC key by default) Click Interface > Social and check - Mature Language Filter.
Once enabled, all inappropriate words in our profanity database will be filtered and masked to appear as jumbled characters, such as ‘*##@&’.
Note: The filter does not excuse the language used. The filter serves as a temporary shield, to help parents of minors and others who do not wish to see it, to block it. Our policies prohibit the use of both clear and masked inappropriate language.