The evolutionary optimality of oscillatory and chaotic dynamics in simple population models