In your example, the filter function is used to define a table which is passed to the calculate function as a filter input. Rewriting the DAX to have the filter function on a single line makes it clearer that the entire filter function result is the only filter being used by the calculate function as a filter input.
Cumulative Sales =
ISBLANK ( [Total Sales] ),
FILTER ( ALLSELECTED ( Dates ), Dates[Date] <= MAX ( Dates[Date] ) )
In terms of why the filter function is being used: This would be to ensure the ALLSELECTED function is used instead of an ALL function when defining the table to pass to calculate.
To explain further. If you had just written
Dates[Date] <= MAX ( Dates[Date] ) as the filter input to calculate, this would be syntax sugar for
FILTER ( ALL ( Dates[Date] ), Dates[Date] <= MAX ( Dates[Date] ) ) which is what the engine converts it to in behind the scenes. This would naturally give you a different result.
I hope this helps your understanding.