
Better luck next time
Encouragement
Used to encourage someone gently after a failure, not to mock them. 
Not Literal
It's not about actual 'luck', but a way to wish someone success in the future. 
Casual
Primarily used in informal conversations among friends or colleagues. 