The xgb.cv function in your code performs k-fold cross validation only. I think you misunderstood this function, it does not change the value of any parameter.
According to your problem if you want to find the best parameter in R, then there are two methods.
To find the best parameters in R's XGBoost, there are some methods. These are 2 methods:
Use mlr package: This package can be used with XG-BOOST to find the best optimal hyperparameter of your model.
Find the best parameters manually: You can try setting up different parameters of your model manually to get the best accuracy. It is a bit time-consuming approach, but sometimes it works early.
Hope this answer helps.