Q:

What should a scrum team do if they complete work earlier than expected?

Our development team estimates that they can complete 30 story points in the current iteration. Partway through the sprint they realize that they will complete 50 story points at their current rate. What we should do? 

A:

Great question, and a great problem to have :)
If a team is ahead of schedule, it's still ultimately up to them as to how to manage their work. I suggest asking them what their stretch goal should be relative to the next highest-value yielding work in the product backlog, all while providing transparency to the PO. There's nothing that says you can't deliver more value than you initially anticipated. 
Also congrats to your team!

A:

What a wonderful problem to have - to be ahead of schedule.
Besides for trying to get ahead on future tasks, I would suggest the following:

Code reviews
Adding comments to the code
Updating specs to match to match the code
Blackbox and whitebox testing of code 
Some fun activity; otherwise you may essentially be punishing the team for doing a great job by giving them more work to do.

