We can use Apex in the following ways
To create Email services
Create web services
Perform complex validation over multiple objects
To create complex business processes that are not supported by workflow.
Create custom transaction logic
Attach custom logic to another operation