We have customers using server versions 10.3.1 through 10.5.1. Are there any compatibility issues with the 3.21 API and current ArcGIS Online / Server 10.5.1 / Runtime 100.x?
I'm not aware of any compatibility issues. My experience has been that sometimes the server has capabilities that haven't surfaced in the JS API yet, but this isn't a compatibility issue really.
You can use the above mentioned versions of ArcGIS server versions with JavaScript 3.21. There would not be any issue.