unsucessful setFieldValues after programatically creating field on a migration
The main issue here ended up being a Craft bug (craftcms/cms#6651), which has been fixed for the next release (3.5.5).
There are a couple ways your code could be improved as well, though:

$fieldGroup is a craft\models\FieldGroup object, not an array, so you should access its ID via $fieldGroup-&gt;id, not $fieldGroup['id']. (Or just use the $groupId property.)

Avoid using === for numeric properties like id, unless you know for certain what the type is going to be. IDs should be casted as integers, not strings, and places where they are strings should be considered a minor bug. (It’s due to how MySQL returns the data, but not an issue in PostgreSQL, and we are working toward always ensuring that they are typed as ints correctly even for MySQL.) Safest thing for you to do is replace === with == on this line:
if ($entryType-&gt;id === '2') {


Your two continue statements should be break. continue just tells the loop to move onto the next cycle of the loop; break tells it to completely break out of the loop.

$tabsForSaving is never defined. I’m surprised that’s not causing a PHP error for you.